@percy/dom 1.28.4-beta.1 → 1.28.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 +2 -43
  2. package/package.json +3 -3
package/dist/bundle.js CHANGED
@@ -55,11 +55,12 @@
55
55
  // Adds a `<base>` element to the serialized iframe's `<head>`. This is necessary when
56
56
  // embedded documents are serialized and their contents become root-relative.
57
57
  function setBaseURI(dom) {
58
+ var _dom$querySelector;
58
59
  /* istanbul ignore if: sanity check */
59
60
  if (!new URL(dom.baseURI).hostname) return;
60
61
  let $base = document.createElement('base');
61
62
  $base.href = dom.baseURI;
62
- dom.querySelector('head').prepend($base);
63
+ (_dom$querySelector = dom.querySelector('head')) === null || _dom$querySelector === void 0 ? void 0 : _dom$querySelector.prepend($base);
63
64
  }
64
65
 
65
66
  // Recursively serializes iframe documents into srcdoc attributes.
@@ -499,45 +500,6 @@
499
500
  return docElement.outerHTML.replace('</html>', () => `${innerHTML}</html>`);
500
501
  }
501
502
 
502
- // we inject declarative shadow dom polyfill to allow shadow dom to load in non chromium infrastructure browsers
503
- // Since only chromium currently supports declarative shadow DOM - https://caniuse.com/declarative-shadow-dom
504
- function injectDeclarativeShadowDOMPolyfill(ctx) {
505
- let clone = ctx.clone;
506
- let scriptEl = document.createElement('script');
507
- scriptEl.setAttribute('id', '__percy_shadowdom_helper');
508
- scriptEl.setAttribute('data-percy-injected', true);
509
- scriptEl.innerHTML = `
510
- function attachShadow(template, mode){
511
- const shadowRoot = template.parentNode.attachShadow({ mode });
512
- shadowRoot.appendChild(template.content);
513
- template.remove();
514
- }
515
-
516
- function reversePolyFill(root=document){
517
- root.querySelectorAll('template[shadowroot]').forEach(template => {
518
- const mode = template.getAttribute('shadowroot');
519
- attachShadow(template, mode);
520
- });
521
-
522
- root.querySelectorAll('template[shadowrootmode]').forEach(template => {
523
- const mode = template.getAttribute('shadowrootmode');
524
- attachShadow(template, mode);
525
- });
526
-
527
- root.querySelectorAll('[data-percy-shadow-host]').forEach(shadowHost => reversePolyFill(shadowHost.shadowRoot));
528
- }
529
-
530
- if (["interactive", "complete"].includes(document.readyState)) {
531
- reversePolyFill();
532
- } else {
533
- document.addEventListener("DOMContentLoaded", () => reversePolyFill());
534
- }
535
- `.replace(/(\n|\s{2}|\t)/g, '');
536
-
537
- // run polyfill as first thing post dom content is loaded
538
- clone.head.prepend(scriptEl);
539
- }
540
-
541
503
  // Returns a copy or new doctype for a document.
542
504
  function doctype(dom) {
543
505
  let {
@@ -622,9 +584,6 @@
622
584
  console.error(errorMessage);
623
585
  }
624
586
  }
625
- if (!disableShadowDOM) {
626
- injectDeclarativeShadowDOMPolyfill(ctx);
627
- }
628
587
  if (reshuffleInvalidTags) {
629
588
  let clonedBody = ctx.clone.body;
630
589
  while (clonedBody.nextSibling) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.28.4-beta.1",
3
+ "version": "1.28.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": "beta"
12
+ "tag": "latest"
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": "6f2c2bdf17f844b1add5f0c675163573893d301e"
38
+ "gitHead": "00ab37414a739e50b28c054da4301f9a7718e880"
39
39
  }