Skip to content

Commit

Permalink
[compat] Skip rendering <noscript> contents on the client (#3238)
Browse files Browse the repository at this point in the history
* [compat] Skip rendering <noscript> contents on the client

This fixes the issue from #2797, and [this issue](https://zenn.dev/d_suke/scraps/f7013c4554ac43) using Next.js's `<Image>` component with Preact.

* Update render.js

Co-authored-by: Jovi De Croock <[email protected]>
  • Loading branch information
developit and JoviDeCroock authored Oct 12, 2021
1 parent 6d0f682 commit d78746c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compat/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const REACT_ELEMENT_TYPE =

const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;

const IS_DOM = typeof document !== 'undefined';

// Input types for which onchange should not be converted to oninput.
// type="file|checkbox|radio", plus "range" in IE11.
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
Expand Down Expand Up @@ -118,7 +120,11 @@ options.vnode = vnode => {
for (let i in props) {
let value = props[i];

if (i === 'value' && 'defaultValue' in props && value == null) {
if (IS_DOM && i === 'children' && type === 'noscript') {
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
continue;
}
else if (i === 'value' && 'defaultValue' in props && value == null) {
// Skip applying value if it is null/undefined and we already set
// a default value
continue;
Expand Down

0 comments on commit d78746c

Please sign in to comment.