@applitools/dom-capture
Advanced tools
Comparing version 6.0.1 to 6.0.2
@@ -235,8 +235,8 @@ | ||
} | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet).map(resourceUrl => | ||
absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet, doc.defaultView).map( | ||
resourceUrl => absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
); | ||
return getResourceUrlsAndBlobs(resourceUrls).then(({resourceUrls, blobsObj}) => ({ | ||
resourceUrls, | ||
blobsObj: {...blobsObj, [url]: {type, value}}, | ||
blobsObj: Object.assign(blobsObj, {[url]: {type, value}}), | ||
})); | ||
@@ -286,21 +286,12 @@ } else { | ||
// TODO share this code with the node part of visual-grid-client | ||
function extractResourcesFromStyleSheet( | ||
styleSheet, | ||
{cssImportRule, cssFontFaceRule, cssSupportsRule, cssMediaRule, cssStyleRule} = { | ||
cssImportRule: CSSImportRule, | ||
cssFontFaceRule: CSSFontFaceRule, | ||
cssSupportsRule: CSSSupportsRule, | ||
cssMediaRule: CSSMediaRule, | ||
cssStyleRule: CSSStyleRule, | ||
}, | ||
) { | ||
function extractResourcesFromStyleSheet(styleSheet, win = window) { | ||
return uniq_1( | ||
[...styleSheet.cssRules].reduce((acc, rule) => { | ||
if (rule instanceof cssImportRule) { | ||
if (rule instanceof win.CSSImportRule) { | ||
return acc.concat(rule.href); | ||
} else if (rule instanceof cssFontFaceRule) { | ||
} else if (rule instanceof win.CSSFontFaceRule) { | ||
return acc.concat(getUrlFromCssText_1(rule.style.getPropertyValue('src'))); | ||
} else if (rule instanceof cssSupportsRule || rule instanceof cssMediaRule) { | ||
} else if (rule instanceof win.CSSSupportsRule || rule instanceof win.CSSMediaRule) { | ||
return acc.concat(extractResourcesFromStyleSheet(rule)); | ||
} else if (rule instanceof cssStyleRule) { | ||
} else if (rule instanceof win.CSSStyleRule) { | ||
for (let i = 0, ii = rule.style.length; i < ii; i++) { | ||
@@ -339,3 +330,3 @@ const urls = getUrlFromCssText_1(rule.style.getPropertyValue(rule.style[i])); | ||
); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet)); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet, doc.defaultView)); | ||
}, []), | ||
@@ -411,6 +402,10 @@ ); | ||
function blobsObjToArray(blobsObj) { | ||
return Object.keys(blobsObj).map(blobUrl => ({ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
...blobsObj[blobUrl], | ||
})); | ||
return Object.keys(blobsObj).map(blobUrl => | ||
Object.assign( | ||
{ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
}, | ||
blobsObj[blobUrl], | ||
), | ||
); | ||
} | ||
@@ -417,0 +412,0 @@ |
@@ -287,8 +287,8 @@ | ||
} | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet).map(resourceUrl => | ||
absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet, doc.defaultView).map( | ||
resourceUrl => absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
); | ||
return getResourceUrlsAndBlobs(resourceUrls).then(({resourceUrls, blobsObj}) => ({ | ||
resourceUrls, | ||
blobsObj: {...blobsObj, [url]: {type, value}}, | ||
blobsObj: Object.assign(blobsObj, {[url]: {type, value}}), | ||
})); | ||
@@ -338,21 +338,12 @@ } else { | ||
// TODO share this code with the node part of visual-grid-client | ||
function extractResourcesFromStyleSheet( | ||
styleSheet, | ||
{cssImportRule, cssFontFaceRule, cssSupportsRule, cssMediaRule, cssStyleRule} = { | ||
cssImportRule: CSSImportRule, | ||
cssFontFaceRule: CSSFontFaceRule, | ||
cssSupportsRule: CSSSupportsRule, | ||
cssMediaRule: CSSMediaRule, | ||
cssStyleRule: CSSStyleRule, | ||
}, | ||
) { | ||
function extractResourcesFromStyleSheet(styleSheet, win = window) { | ||
return uniq_1( | ||
[...styleSheet.cssRules].reduce((acc, rule) => { | ||
if (rule instanceof cssImportRule) { | ||
if (rule instanceof win.CSSImportRule) { | ||
return acc.concat(rule.href); | ||
} else if (rule instanceof cssFontFaceRule) { | ||
} else if (rule instanceof win.CSSFontFaceRule) { | ||
return acc.concat(getUrlFromCssText_1(rule.style.getPropertyValue('src'))); | ||
} else if (rule instanceof cssSupportsRule || rule instanceof cssMediaRule) { | ||
} else if (rule instanceof win.CSSSupportsRule || rule instanceof win.CSSMediaRule) { | ||
return acc.concat(extractResourcesFromStyleSheet(rule)); | ||
} else if (rule instanceof cssStyleRule) { | ||
} else if (rule instanceof win.CSSStyleRule) { | ||
for (let i = 0, ii = rule.style.length; i < ii; i++) { | ||
@@ -391,3 +382,3 @@ const urls = getUrlFromCssText_1(rule.style.getPropertyValue(rule.style[i])); | ||
); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet)); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet, doc.defaultView)); | ||
}, []), | ||
@@ -463,6 +454,10 @@ ); | ||
function blobsObjToArray(blobsObj) { | ||
return Object.keys(blobsObj).map(blobUrl => ({ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
...blobsObj[blobUrl], | ||
})); | ||
return Object.keys(blobsObj).map(blobUrl => | ||
Object.assign( | ||
{ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
}, | ||
blobsObj[blobUrl], | ||
), | ||
); | ||
} | ||
@@ -469,0 +464,0 @@ |
{ | ||
"name": "@applitools/dom-capture", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,21 +6,12 @@ 'use strict'; | ||
// TODO share this code with the node part of visual-grid-client | ||
function extractResourcesFromStyleSheet( | ||
styleSheet, | ||
{cssImportRule, cssFontFaceRule, cssSupportsRule, cssMediaRule, cssStyleRule} = { | ||
cssImportRule: CSSImportRule, | ||
cssFontFaceRule: CSSFontFaceRule, | ||
cssSupportsRule: CSSSupportsRule, | ||
cssMediaRule: CSSMediaRule, | ||
cssStyleRule: CSSStyleRule, | ||
}, | ||
) { | ||
function extractResourcesFromStyleSheet(styleSheet, win = window) { | ||
return uniq( | ||
[...styleSheet.cssRules].reduce((acc, rule) => { | ||
if (rule instanceof cssImportRule) { | ||
if (rule instanceof win.CSSImportRule) { | ||
return acc.concat(rule.href); | ||
} else if (rule instanceof cssFontFaceRule) { | ||
} else if (rule instanceof win.CSSFontFaceRule) { | ||
return acc.concat(getUrlFromCssText(rule.style.getPropertyValue('src'))); | ||
} else if (rule instanceof cssSupportsRule || rule instanceof cssMediaRule) { | ||
} else if (rule instanceof win.CSSSupportsRule || rule instanceof win.CSSMediaRule) { | ||
return acc.concat(extractResourcesFromStyleSheet(rule)); | ||
} else if (rule instanceof cssStyleRule) { | ||
} else if (rule instanceof win.CSSStyleRule) { | ||
for (let i = 0, ii = rule.style.length; i < ii; i++) { | ||
@@ -27,0 +18,0 @@ const urls = getUrlFromCssText(rule.style.getPropertyValue(rule.style[i])); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet)); | ||
return resourceUrls.concat(extractResourcesFromStyleSheet(styleSheet, doc.defaultView)); | ||
}, []), | ||
@@ -14,0 +14,0 @@ ); |
@@ -73,8 +73,12 @@ 'use strict'; | ||
function blobsObjToArray(blobsObj) { | ||
return Object.keys(blobsObj).map(blobUrl => ({ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
...blobsObj[blobUrl], | ||
})); | ||
return Object.keys(blobsObj).map(blobUrl => | ||
Object.assign( | ||
{ | ||
url: blobUrl.replace(/^blob:/, ''), | ||
}, | ||
blobsObj[blobUrl], | ||
), | ||
); | ||
} | ||
module.exports = processPage; |
@@ -21,8 +21,8 @@ 'use strict'; | ||
} | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet).map(resourceUrl => | ||
absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
const resourceUrls = extractResourcesFromStyleSheet(styleSheet, doc.defaultView).map( | ||
resourceUrl => absolutizeUrl(resourceUrl, url.replace(/^blob:/, '')), | ||
); | ||
return getResourceUrlsAndBlobs(resourceUrls).then(({resourceUrls, blobsObj}) => ({ | ||
resourceUrls, | ||
blobsObj: {...blobsObj, [url]: {type, value}}, | ||
blobsObj: Object.assign(blobsObj, {[url]: {type, value}}), | ||
})); | ||
@@ -29,0 +29,0 @@ } else { |
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
71911
1989