@percy/dom 1.31.2-beta.0 → 1.31.2-beta.1

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/README.md CHANGED
@@ -65,7 +65,7 @@ to a new stylesheet inserted into the document's head.
65
65
  Canvas elements' drawing buffers are serialized as data URIs and the canvas elements are replaced
66
66
  with image elements. The image elements reference the serialized data URI and have the same HTML
67
67
  attributes as their respective canvas elements. The image elements also have a max-width of 100% to
68
- accomidate responsive layouts in situations where canvases may be expected to resize with JS.
68
+ accommodate responsive layouts in situations where canvases may be expected to resize with JS.
69
69
 
70
70
  ### Video elements
71
71
 
package/dist/bundle.js CHANGED
@@ -459,10 +459,24 @@
459
459
  if (!['img', 'iframe'].includes((_domElement$tagName = domElement.tagName) === null || _domElement$tagName === void 0 ? void 0 : _domElement$tagName.toLowerCase())) return;
460
460
  domElement.removeAttribute('loading');
461
461
  }
462
+ function serializeScrollState(original, clone) {
463
+ if (!original || !clone) return;
464
+
465
+ // Check and set scrollTop if it exists and has a value
466
+ if (typeof original.scrollTop === 'number' && original.scrollTop !== 0) {
467
+ clone.setAttribute('data-percy-scrolltop', original.scrollTop.toString());
468
+ }
469
+
470
+ // Check and set scrollLeft if it exists and has a value
471
+ if (typeof original.scrollLeft === 'number' && original.scrollLeft !== 0) {
472
+ clone.setAttribute('data-percy-scrollleft', original.scrollLeft.toString());
473
+ }
474
+ }
462
475
 
463
476
  // All transformations that we need to apply for a successful discovery and stable render
464
- function applyElementTransformations(domElement) {
477
+ function applyElementTransformations(originalElement, domElement) {
465
478
  dropLoadingAttribute(domElement);
479
+ serializeScrollState(originalElement, domElement);
466
480
  }
467
481
 
468
482
  let mimetype = null;
@@ -592,7 +606,7 @@
592
606
  }
593
607
 
594
608
  // We apply any element transformations here to avoid another treeWalk
595
- applyElementTransformations(clone);
609
+ applyElementTransformations(node, clone);
596
610
  serializeBase64(clone, resources, cache);
597
611
  parent.appendChild(clone);
598
612
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.31.2-beta.0",
3
+ "version": "1.31.2-beta.1",
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": "6d36e464efaa1261bf1f1e7c7302c64cc85eccc7"
38
+ "gitHead": "c8ba03fdd3ab7543f741a68eb5c357e38b48129e"
39
39
  }