Skip to content

Commit 27a4250

Browse files
committed
Wrap <noscript> into a <div> to get its "client HTML"
1 parent 1c327df commit 27a4250

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/renderers/dom/fiber/ReactDOMFiberComponent.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ if (__DEV__) {
179179
parent.tagName,
180180
);
181181
testElement.innerHTML = html;
182+
183+
if (parent.tagName === 'NOSCRIPT') {
184+
// <noscript> content is parsed as text, but only if the browser parses it
185+
// together with <noscript> tag itself. So we have to wrap it once more.
186+
var wrapperElement = document.createElement('div');
187+
wrapperElement.innerHTML = '<noscript>' + html + '</noscript>';
188+
var noscriptElement = wrapperElement.firstElementChild;
189+
// Make Flow happy (but it'll always be there).
190+
if (noscriptElement !== null && typeof noscriptElement !== 'undefined') {
191+
return noscriptElement.innerHTML;
192+
}
193+
}
194+
182195
return testElement.innerHTML;
183196
};
184197
}

0 commit comments

Comments
 (0)