Skip to content

Commit

Permalink
[PER-2574] Icons not loading when noscript tags are present. (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
shantanuk-browserstack authored Oct 19, 2023
1 parent d83228a commit 04146d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dom/src/clone-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
8 changes: 8 additions & 0 deletions packages/dom/test/serialize-dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ describe('serializeDOM', () => {
expect(result.html).toContain('Hey Percy $&');
});

it('excludes noscript tags when present', () => {
withExample('<p>Hey Percy $&</p><noscript>Your browser does not support JavaScript!</noscript>');

const result = serializeDOM();
expect(result.html).not.toContain('<noscript>');
expect(result.html).toContain('Hey Percy $&');
});

it('optionally returns a stringified response', () => {
expect(serializeDOM({ stringifyResponse: true }))
.toMatch('{"html":".*","warnings":\\[\\],"resources":\\[\\]}');
Expand Down

0 comments on commit 04146d1

Please sign in to comment.