@percy/dom 1.31.11 → 1.31.12-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.
Files changed (2) hide show
  1. package/dist/bundle.js +34 -1
  2. package/package.json +3 -3
package/dist/bundle.js CHANGED
@@ -228,7 +228,7 @@
228
228
  function markElement(domElement, disableShadowDOM, forceShadowAsLightDOM) {
229
229
  var _domElement$tagName;
230
230
  // Mark elements that are to be serialized later with a data attribute.
231
- if (['input', 'textarea', 'select', 'iframe', 'canvas', 'video', 'style'].includes((_domElement$tagName = domElement.tagName) === null || _domElement$tagName === void 0 ? void 0 : _domElement$tagName.toLowerCase())) {
231
+ if (['input', 'textarea', 'select', 'iframe', 'canvas', 'video', 'style', 'dialog'].includes((_domElement$tagName = domElement.tagName) === null || _domElement$tagName === void 0 ? void 0 : _domElement$tagName.toLowerCase())) {
232
232
  if (!domElement.getAttribute('data-percy-element-id')) {
233
233
  domElement.setAttribute('data-percy-element-id', uid());
234
234
  }
@@ -670,6 +670,38 @@
670
670
  }
671
671
  }
672
672
 
673
+ // Serializes open <dialog> elements opened via showModal().
674
+ //
675
+ // The browser's ::backdrop and top-layer positioning are lost during
676
+ // DOM serialization. We stamp data-percy-dialog-modal so the renderer
677
+ // can call removeAttribute('open') then showModal() to restore them.
678
+ //
679
+ // The open attribute is kept so the dialog is visible during Percy's
680
+ // asset discovery and rendering phases.
681
+ function serializeDialogs(ctx) {
682
+ let {
683
+ dom,
684
+ clone
685
+ } = ctx;
686
+ for (let elem of dom.querySelectorAll('dialog[open]')) {
687
+ try {
688
+ let dialogId = elem.getAttribute('data-percy-element-id');
689
+ if (!dialogId) continue;
690
+ let cloneEl = clone.querySelector(`[data-percy-element-id="${dialogId}"]`);
691
+ if (!cloneEl) continue;
692
+
693
+ // Detect showModal() vs show()/setAttribute:
694
+ // :modal pseudo-class matches only dialogs in the top layer (opened via showModal())
695
+ if (!elem.matches(':modal')) continue;
696
+
697
+ // Mark for renderer — it will removeAttribute('open') then showModal()
698
+ cloneEl.setAttribute('data-percy-dialog-modal', 'true');
699
+ } catch (err) {
700
+ handleErrors(err, 'Error serializing dialog element: ', elem);
701
+ }
702
+ }
703
+ }
704
+
673
705
  // Drop loading attribute. We do not scroll page in discovery stage but we want to make sure that
674
706
  // all resources are requested, so we drop loading attribute [as it can be set to lazy]
675
707
  function dropLoadingAttribute(domElement) {
@@ -950,6 +982,7 @@
950
982
  serializeInputElements(ctx);
951
983
  serializeFrames(ctx);
952
984
  serializeVideos(ctx);
985
+ serializeDialogs(ctx);
953
986
  if (!ctx.enableJavaScript) {
954
987
  serializeCSSOM(ctx);
955
988
  serializeCanvas(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.31.11",
3
+ "version": "1.31.12-beta.0",
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": "latest"
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": "1f8ad9da90c9a42f8ae678f33dc4198f7d2a32d0"
38
+ "gitHead": "65b6c76698560f85ef40bcb1687bcb2d4f409c61"
39
39
  }