@percy/dom 1.20.0 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +17 -18
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -336,8 +336,15 @@
|
|
|
336
336
|
* https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#parameters
|
|
337
337
|
*/
|
|
338
338
|
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Deep clone a document while also preserving shadow roots
|
|
341
|
+
* returns document fragment
|
|
342
|
+
*/
|
|
343
|
+
function cloneNodeAndShadow(_ref) {
|
|
344
|
+
let {
|
|
345
|
+
dom,
|
|
346
|
+
disableShadowDOM
|
|
347
|
+
} = _ref;
|
|
341
348
|
// clones shadow DOM and light DOM for a given node
|
|
342
349
|
let cloneNode = (node, parent) => {
|
|
343
350
|
let walkTree = (nextn, nextp) => {
|
|
@@ -370,26 +377,18 @@
|
|
|
370
377
|
// clone light DOM
|
|
371
378
|
walkTree(node.firstChild, clone);
|
|
372
379
|
};
|
|
373
|
-
let fragment =
|
|
374
|
-
cloneNode(
|
|
380
|
+
let fragment = dom.createDocumentFragment();
|
|
381
|
+
cloneNode(dom.documentElement, fragment);
|
|
382
|
+
fragment.documentElement = fragment.firstChild;
|
|
383
|
+
fragment.head = fragment.querySelector('head');
|
|
384
|
+
fragment.body = fragment.querySelector('body');
|
|
375
385
|
return fragment;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Deep clone a document while also preserving shadow roots and converting adoptedStylesheets to <style> tags.
|
|
380
|
-
*/
|
|
381
|
-
const cloneNodeAndShadow = ctx => {
|
|
382
|
-
let cloneDocumentFragment = deepClone(ctx.dom.documentElement, ctx.disableShadowDOM);
|
|
383
|
-
cloneDocumentFragment.documentElement = cloneDocumentFragment.firstChild;
|
|
384
|
-
cloneDocumentFragment.head = cloneDocumentFragment.querySelector('head');
|
|
385
|
-
cloneDocumentFragment.body = cloneDocumentFragment.querySelector('body');
|
|
386
|
-
return cloneDocumentFragment;
|
|
387
|
-
};
|
|
386
|
+
}
|
|
388
387
|
|
|
389
388
|
/**
|
|
390
389
|
* Use `getInnerHTML()` to serialize shadow dom as <template> tags. `innerHTML` and `outerHTML` don't do this. Buzzword: "declarative shadow dom"
|
|
391
390
|
*/
|
|
392
|
-
|
|
391
|
+
function getOuterHTML(docElement) {
|
|
393
392
|
// firefox doesn't serialize shadow DOM, we're awaiting API's by firefox to become ready and are not polyfilling it.
|
|
394
393
|
if (!docElement.getInnerHTML) {
|
|
395
394
|
return docElement.outerHTML;
|
|
@@ -400,7 +399,7 @@
|
|
|
400
399
|
});
|
|
401
400
|
docElement.textContent = '';
|
|
402
401
|
return docElement.outerHTML.replace('</html>', `${innerHTML}</html>`);
|
|
403
|
-
}
|
|
402
|
+
}
|
|
404
403
|
|
|
405
404
|
// we inject declarative shadow dom polyfill to allow shadow dom to load in non chromium infrastructure browsers
|
|
406
405
|
// Since only chromium currently supports declarative shadow DOM - https://caniuse.com/declarative-shadow-dom
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"interactor.js": "^2.0.0-beta.10"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "eb789262833734cfc4b7dbb888e889f571eb886e"
|
|
38
38
|
}
|