@percy/dom
Advanced tools
Comparing version 1.28.7 to 1.28.8-beta.0
@@ -223,29 +223,38 @@ (function() { | ||
// in-memory CSSOM into their respective DOM nodes. | ||
for (let styleSheet of dom.styleSheets) { | ||
var _styleSheet$href; | ||
if (isCSSOM(styleSheet)) { | ||
let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id'); | ||
let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`); | ||
if (styleSheetsMatch(styleSheet, styleSheetFromNode(cloneOwnerNode))) continue; | ||
let style = document.createElement('style'); | ||
style.type = 'text/css'; | ||
style.setAttribute('data-percy-element-id', styleId); | ||
style.setAttribute('data-percy-cssom-serialized', 'true'); | ||
style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n'); | ||
cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling); | ||
cloneOwnerNode.remove(); | ||
} else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) { | ||
const styleLink = document.createElement('link'); | ||
styleLink.setAttribute('rel', 'stylesheet'); | ||
let resource = createStyleResource(styleSheet); | ||
resources.add(resource); | ||
styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true'); | ||
styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url); | ||
let styleSheets = null; | ||
// catch error in case styleSheets property is not available (overwritten to throw error) | ||
try { | ||
styleSheets = dom.styleSheets; | ||
} catch { | ||
warnings.add('Skipping `styleSheets` as it is not supported.'); | ||
} | ||
if (styleSheets) { | ||
for (let styleSheet of styleSheets) { | ||
var _styleSheet$href; | ||
if (isCSSOM(styleSheet)) { | ||
let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id'); | ||
let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`); | ||
if (styleSheetsMatch(styleSheet, styleSheetFromNode(cloneOwnerNode))) continue; | ||
let style = document.createElement('style'); | ||
style.type = 'text/css'; | ||
style.setAttribute('data-percy-element-id', styleId); | ||
style.setAttribute('data-percy-cssom-serialized', 'true'); | ||
style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n'); | ||
cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling); | ||
cloneOwnerNode.remove(); | ||
} else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) { | ||
const styleLink = document.createElement('link'); | ||
styleLink.setAttribute('rel', 'stylesheet'); | ||
let resource = createStyleResource(styleSheet); | ||
resources.add(resource); | ||
styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true'); | ||
styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url); | ||
/* istanbul ignore next: tested, but coverage is stripped */ | ||
if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') { | ||
// handle document and iframe | ||
clone.body.prepend(styleLink); | ||
} else if (clone.constructor.name === 'ShadowRoot') { | ||
clone.prepend(styleLink); | ||
/* istanbul ignore next: tested, but coverage is stripped */ | ||
if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') { | ||
// handle document and iframe | ||
clone.body.prepend(styleLink); | ||
} else if (clone.constructor.name === 'ShadowRoot') { | ||
clone.prepend(styleLink); | ||
} | ||
} | ||
@@ -252,0 +261,0 @@ } |
{ | ||
"name": "@percy/dom", | ||
"version": "1.28.7", | ||
"version": "1.28.8-beta.0", | ||
"license": "MIT", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"access": "public", | ||
"tag": "latest" | ||
"tag": "beta" | ||
}, | ||
@@ -39,3 +39,3 @@ "main": "dist/bundle.js", | ||
}, | ||
"gitHead": "d920b185772c020b9df6719142623844aeccb9af" | ||
"gitHead": "866f110837fabc0607d9b817b2e4373bc91bc474" | ||
} |
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
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
32383
617
2