Skip to content

Commit 4bf3073

Browse files
authored
Found an example in the wild of the deprecated pre-css way of adding a background image to table cells (#69)
1 parent 8307c87 commit 4bf3073

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/snapshot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,15 @@ function getHref() {
158158

159159
export function transformAttribute(
160160
doc: Document,
161+
tagName: string,
161162
name: string,
162163
value: string,
163164
): string {
164165
// relative path in attribute
165166
if (name === 'src' || ((name === 'href' || name === 'xlink:href') && value)) {
166167
return absoluteToDoc(doc, value);
168+
} else if (name === 'background' && value && (tagName === 'table' || tagName == 'td' || tagName == 'th')) {
169+
return absoluteToDoc(doc, value);
167170
} else if (name === 'srcset' && value) {
168171
return getAbsoluteSrcsetString(doc, value);
169172
} else if (name === 'style' && value) {
@@ -294,7 +297,7 @@ function serializeNode(
294297
const tagName = getValidTagName(n as HTMLElement);
295298
let attributes: attributes = {};
296299
for (const { name, value } of Array.from((n as HTMLElement).attributes)) {
297-
attributes[name] = transformAttribute(doc, name, value);
300+
attributes[name] = transformAttribute(doc, tagName, name, value);
298301
}
299302
// remote css
300303
if (tagName === 'link' && inlineStylesheet) {

0 commit comments

Comments
 (0)