@percy/dom 1.24.1 → 1.24.3-beta.0
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 +19 -1
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -328,6 +328,19 @@
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
// Drop loading attribute. We do not scroll page in discovery stage but we want to make sure that
|
|
332
|
+
// all resources are requested, so we drop loading attribute [as it can be set to lazy]
|
|
333
|
+
function dropLoadingAttribute(domElement) {
|
|
334
|
+
var _domElement$tagName;
|
|
335
|
+
if (!['img', 'iframe'].includes((_domElement$tagName = domElement.tagName) === null || _domElement$tagName === void 0 ? void 0 : _domElement$tagName.toLowerCase())) return;
|
|
336
|
+
domElement.removeAttribute('loading');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// All transformations that we need to apply for a successful discovery and stable render
|
|
340
|
+
function applyElementTransformations(domElement) {
|
|
341
|
+
dropLoadingAttribute(domElement);
|
|
342
|
+
}
|
|
343
|
+
|
|
331
344
|
/**
|
|
332
345
|
* Custom deep clone function that replaces Percy's current clone behavior.
|
|
333
346
|
* This enables us to capture shadow DOM in snapshots. It takes advantage of `attachShadow`'s mode option set to open
|
|
@@ -355,6 +368,9 @@
|
|
|
355
368
|
// mark the node before cloning
|
|
356
369
|
markElement(node, disableShadowDOM);
|
|
357
370
|
let clone = node.cloneNode();
|
|
371
|
+
|
|
372
|
+
// We apply any element transformations here to avoid another treeWalk
|
|
373
|
+
applyElementTransformations(clone);
|
|
358
374
|
parent.appendChild(clone);
|
|
359
375
|
|
|
360
376
|
// shallow clone should not contain children
|
|
@@ -401,7 +417,9 @@
|
|
|
401
417
|
includeShadowRoots: true
|
|
402
418
|
});
|
|
403
419
|
docElement.textContent = '';
|
|
404
|
-
|
|
420
|
+
// Note: Here we are specifically passing replacer function to avoid any replacements due to
|
|
421
|
+
// special characters in client's dom like $&
|
|
422
|
+
return docElement.outerHTML.replace('</html>', () => `${innerHTML}</html>`);
|
|
405
423
|
}
|
|
406
424
|
|
|
407
425
|
// we inject declarative shadow dom polyfill to allow shadow dom to load in non chromium infrastructure browsers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.3-beta.0",
|
|
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": "1c5664ca09f7f3b3d3c20484348ee748295dd1e2"
|
|
38
38
|
}
|