@percy/dom 1.28.2-beta.0 → 1.28.2-beta.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 +25 -1
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -369,6 +369,28 @@
|
|
|
369
369
|
dropLoadingAttribute(domElement);
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
let mimetype = null;
|
|
373
|
+
function getBase64Substring(src) {
|
|
374
|
+
let base64Index = src.indexOf(';base64,');
|
|
375
|
+
if (base64Index === -1) return null;
|
|
376
|
+
mimetype = src.substring(5, base64Index);
|
|
377
|
+
base64Index += ';base64,'.length;
|
|
378
|
+
return src.substring(base64Index);
|
|
379
|
+
}
|
|
380
|
+
function serializeBase64(node, resources) {
|
|
381
|
+
let src = node.src;
|
|
382
|
+
// skip if src is null
|
|
383
|
+
if (src == null) return;
|
|
384
|
+
let base64String = getBase64Substring(src);
|
|
385
|
+
// skip if src is not base64
|
|
386
|
+
if (base64String == null) return;
|
|
387
|
+
|
|
388
|
+
// create a resource from the serialized data url
|
|
389
|
+
let resource = resourceFromText(uid(), mimetype, base64String);
|
|
390
|
+
resources.add(resource);
|
|
391
|
+
node.src = resource.url;
|
|
392
|
+
}
|
|
393
|
+
|
|
372
394
|
/**
|
|
373
395
|
* Custom deep clone function that replaces Percy's current clone behavior.
|
|
374
396
|
* This enables us to capture shadow DOM in snapshots. It takes advantage of `attachShadow`'s mode option set to open
|
|
@@ -384,7 +406,8 @@
|
|
|
384
406
|
function cloneNodeAndShadow(_ref) {
|
|
385
407
|
let {
|
|
386
408
|
dom,
|
|
387
|
-
disableShadowDOM
|
|
409
|
+
disableShadowDOM,
|
|
410
|
+
resources
|
|
388
411
|
} = _ref;
|
|
389
412
|
// clones shadow DOM and light DOM for a given node
|
|
390
413
|
let cloneNode = (node, parent) => {
|
|
@@ -403,6 +426,7 @@
|
|
|
403
426
|
|
|
404
427
|
// We apply any element transformations here to avoid another treeWalk
|
|
405
428
|
applyElementTransformations(clone);
|
|
429
|
+
serializeBase64(clone, resources);
|
|
406
430
|
parent.appendChild(clone);
|
|
407
431
|
|
|
408
432
|
// shallow clone should not contain children
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.28.2-beta.
|
|
3
|
+
"version": "1.28.2-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"interactor.js": "^2.0.0-beta.10"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "7c2bdccd896be9da7d07dd30ead802fbb4ca9fab"
|
|
39
39
|
}
|