Capture stylesheets designated as rel="preload" (#1374)
* feat(Snapshot): Capture stylesheets designated as `rel="preload"` * fix(Snapshot): Harden asset file extension matching * Add changeset * chore: Lint * Tweak regex, add try-catch block on URL constructor
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
stringifyStylesheet,
|
||||
getInputType,
|
||||
toLowerCase,
|
||||
extractFileExtension,
|
||||
} from './utils';
|
||||
|
||||
let _id = 1;
|
||||
@@ -847,7 +848,7 @@ function slimDOMExcluded(
|
||||
(sn.tagName === 'link' &&
|
||||
sn.attributes.rel === 'prefetch' &&
|
||||
typeof sn.attributes.href === 'string' &&
|
||||
sn.attributes.href.endsWith('.js')))
|
||||
extractFileExtension(sn.attributes.href) === 'js'))
|
||||
) {
|
||||
return true;
|
||||
} else if (
|
||||
@@ -1177,7 +1178,11 @@ export function serializeNodeWithId(
|
||||
if (
|
||||
serializedNode.type === NodeType.Element &&
|
||||
serializedNode.tagName === 'link' &&
|
||||
serializedNode.attributes.rel === 'stylesheet'
|
||||
typeof serializedNode.attributes.rel === 'string' &&
|
||||
(serializedNode.attributes.rel === 'stylesheet' ||
|
||||
(serializedNode.attributes.rel === 'preload' &&
|
||||
typeof serializedNode.attributes.href === 'string' &&
|
||||
extractFileExtension(serializedNode.attributes.href) === 'css'))
|
||||
) {
|
||||
onceStylesheetLoaded(
|
||||
n as HTMLLinkElement,
|
||||
|
||||
Reference in New Issue
Block a user