@percy/dom
Advanced tools
Comparing version 1.28.4-beta.1 to 1.28.4
@@ -58,2 +58,3 @@ (function() { | ||
function setBaseURI(dom) { | ||
var _dom$querySelector; | ||
/* istanbul ignore if: sanity check */ | ||
@@ -63,3 +64,3 @@ if (!new URL(dom.baseURI).hostname) return; | ||
$base.href = dom.baseURI; | ||
dom.querySelector('head').prepend($base); | ||
(_dom$querySelector = dom.querySelector('head')) === null || _dom$querySelector === void 0 ? void 0 : _dom$querySelector.prepend($base); | ||
} | ||
@@ -504,41 +505,2 @@ | ||
// we inject declarative shadow dom polyfill to allow shadow dom to load in non chromium infrastructure browsers | ||
// Since only chromium currently supports declarative shadow DOM - https://caniuse.com/declarative-shadow-dom | ||
function injectDeclarativeShadowDOMPolyfill(ctx) { | ||
let clone = ctx.clone; | ||
let scriptEl = document.createElement('script'); | ||
scriptEl.setAttribute('id', '__percy_shadowdom_helper'); | ||
scriptEl.setAttribute('data-percy-injected', true); | ||
scriptEl.innerHTML = ` | ||
function attachShadow(template, mode){ | ||
const shadowRoot = template.parentNode.attachShadow({ mode }); | ||
shadowRoot.appendChild(template.content); | ||
template.remove(); | ||
} | ||
function reversePolyFill(root=document){ | ||
root.querySelectorAll('template[shadowroot]').forEach(template => { | ||
const mode = template.getAttribute('shadowroot'); | ||
attachShadow(template, mode); | ||
}); | ||
root.querySelectorAll('template[shadowrootmode]').forEach(template => { | ||
const mode = template.getAttribute('shadowrootmode'); | ||
attachShadow(template, mode); | ||
}); | ||
root.querySelectorAll('[data-percy-shadow-host]').forEach(shadowHost => reversePolyFill(shadowHost.shadowRoot)); | ||
} | ||
if (["interactive", "complete"].includes(document.readyState)) { | ||
reversePolyFill(); | ||
} else { | ||
document.addEventListener("DOMContentLoaded", () => reversePolyFill()); | ||
} | ||
`.replace(/(\n|\s{2}|\t)/g, ''); | ||
// run polyfill as first thing post dom content is loaded | ||
clone.head.prepend(scriptEl); | ||
} | ||
// Returns a copy or new doctype for a document. | ||
@@ -628,5 +590,2 @@ function doctype(dom) { | ||
} | ||
if (!disableShadowDOM) { | ||
injectDeclarativeShadowDOMPolyfill(ctx); | ||
} | ||
if (reshuffleInvalidTags) { | ||
@@ -633,0 +592,0 @@ let clonedBody = ctx.clone.body; |
{ | ||
"name": "@percy/dom", | ||
"version": "1.28.4-beta.1", | ||
"version": "1.28.4", | ||
"license": "MIT", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"access": "public", | ||
"tag": "beta" | ||
"tag": "latest" | ||
}, | ||
@@ -39,3 +39,3 @@ "main": "dist/bundle.js", | ||
}, | ||
"gitHead": "6f2c2bdf17f844b1add5f0c675163573893d301e" | ||
"gitHead": "00ab37414a739e50b28c054da4301f9a7718e880" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
32018
608