@percy/dom 1.28.1-alpha.2 → 1.28.1-alpha.4

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.
Files changed (2) hide show
  1. package/dist/bundle.js +25 -1
  2. package/package.json +3 -3
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,12 +406,14 @@
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) => {
391
414
  let walkTree = (nextn, nextp) => {
392
415
  while (nextn) {
416
+ serializeBase64(nextn, resources);
393
417
  if (!ignoreTags.includes(nextn.nodeName)) {
394
418
  cloneNode(nextn, nextp);
395
419
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.28.1-alpha.2",
3
+ "version": "1.28.1-alpha.4",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "alpha"
12
+ "tag": "beta"
13
13
  },
14
14
  "main": "dist/bundle.js",
15
15
  "browser": "dist/bundle.js",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "interactor.js": "^2.0.0-beta.10"
37
37
  },
38
- "gitHead": "a3f2e709d0a6445e15a1128686578b1659243a95"
38
+ "gitHead": "90d1c1135441a631d5fdbbce0a7e2efbe8ab4e21"
39
39
  }