diff --git a/packages/dom/src/clone-dom.js b/packages/dom/src/clone-dom.js index 37ca0c9d0..257f2d8e2 100644 --- a/packages/dom/src/clone-dom.js +++ b/packages/dom/src/clone-dom.js @@ -10,12 +10,17 @@ import applyElementTransformations from './transform-dom'; * Deep clone a document while also preserving shadow roots * returns document fragment */ + +const ignoreTags = ['NOSCRIPT']; + export function cloneNodeAndShadow({ dom, disableShadowDOM }) { // clones shadow DOM and light DOM for a given node let cloneNode = (node, parent) => { let walkTree = (nextn, nextp) => { while (nextn) { - cloneNode(nextn, nextp); + if (!ignoreTags.includes(nextn.nodeName)) { + cloneNode(nextn, nextp); + } nextn = nextn.nextSibling; } }; diff --git a/packages/dom/test/serialize-dom.test.js b/packages/dom/test/serialize-dom.test.js index 2fa38f6d0..1da2d53ee 100644 --- a/packages/dom/test/serialize-dom.test.js +++ b/packages/dom/test/serialize-dom.test.js @@ -17,6 +17,14 @@ describe('serializeDOM', () => { expect(result.html).toContain('Hey Percy $&'); }); + it('excludes noscript tags when present', () => { + withExample('
Hey Percy $&
'); + + const result = serializeDOM(); + expect(result.html).not.toContain('