Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compat] Skip rendering <noscript> contents on the client #3238

Merged
merged 3 commits into from
Oct 12, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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|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 @@ -117,7 +119,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