diff --git a/src/snapshot.ts b/src/snapshot.ts index 8c8233e1..167768f2 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -146,11 +146,11 @@ export function transformAttribute( value: string, ): string { // relative path in attribute - if (name === 'src' || name === 'href') { + if (name === 'src' || (name === 'href' && value)) { return absoluteToDoc(doc, value); - } else if (name === 'srcset') { + } else if (name === 'srcset' && value) { return getAbsoluteSrcsetString(doc, value); - } else if (name === 'style') { + } else if (name === 'style' && value) { return absoluteToStylesheet(value, location.href); } else { return value; diff --git a/test/__snapshots__/integration.ts.snap b/test/__snapshots__/integration.ts.snap index f04f33ad..363fd658 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -75,12 +75,14 @@ exports[`[html file]: block-element.html 1`] = ` exports[`[html file]: cors-style-sheet.html 1`] = ` "
- - - -