Skip to content

Commit d78746c

Browse files
[compat] Skip rendering <noscript> contents on the client (#3238)
* [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 <decroockjovi@gmail.com>
1 parent 6d0f682 commit d78746c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

compat/src/render.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const REACT_ELEMENT_TYPE =
1212

1313
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]/;
1414

15+
const IS_DOM = typeof document !== 'undefined';
16+
1517
// Input types for which onchange should not be converted to oninput.
1618
// type="file|checkbox|radio", plus "range" in IE11.
1719
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
@@ -118,7 +120,11 @@ options.vnode = vnode => {
118120
for (let i in props) {
119121
let value = props[i];
120122

121-
if (i === 'value' && 'defaultValue' in props && value == null) {
123+
if (IS_DOM && i === 'children' && type === 'noscript') {
124+
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
125+
continue;
126+
}
127+
else if (i === 'value' && 'defaultValue' in props && value == null) {
122128
// Skip applying value if it is null/undefined and we already set
123129
// a default value
124130
continue;

0 commit comments

Comments
 (0)