Found an example in the wild of the deprecated pre-css way of adding a background image to table cells (#69)
This commit is contained in:
@@ -158,12 +158,15 @@ function getHref() {
|
|||||||
|
|
||||||
export function transformAttribute(
|
export function transformAttribute(
|
||||||
doc: Document,
|
doc: Document,
|
||||||
|
tagName: string,
|
||||||
name: string,
|
name: string,
|
||||||
value: string,
|
value: string,
|
||||||
): string {
|
): string {
|
||||||
// relative path in attribute
|
// relative path in attribute
|
||||||
if (name === 'src' || ((name === 'href' || name === 'xlink:href') && value)) {
|
if (name === 'src' || ((name === 'href' || name === 'xlink:href') && value)) {
|
||||||
return absoluteToDoc(doc, value);
|
return absoluteToDoc(doc, value);
|
||||||
|
} else if (name === 'background' && value && (tagName === 'table' || tagName == 'td' || tagName == 'th')) {
|
||||||
|
return absoluteToDoc(doc, value);
|
||||||
} else if (name === 'srcset' && value) {
|
} else if (name === 'srcset' && value) {
|
||||||
return getAbsoluteSrcsetString(doc, value);
|
return getAbsoluteSrcsetString(doc, value);
|
||||||
} else if (name === 'style' && value) {
|
} else if (name === 'style' && value) {
|
||||||
@@ -294,7 +297,7 @@ function serializeNode(
|
|||||||
const tagName = getValidTagName(n as HTMLElement);
|
const tagName = getValidTagName(n as HTMLElement);
|
||||||
let attributes: attributes = {};
|
let attributes: attributes = {};
|
||||||
for (const { name, value } of Array.from((n as HTMLElement).attributes)) {
|
for (const { name, value } of Array.from((n as HTMLElement).attributes)) {
|
||||||
attributes[name] = transformAttribute(doc, name, value);
|
attributes[name] = transformAttribute(doc, tagName, name, value);
|
||||||
}
|
}
|
||||||
// remote css
|
// remote css
|
||||||
if (tagName === 'link' && inlineStylesheet) {
|
if (tagName === 'link' && inlineStylesheet) {
|
||||||
|
|||||||
Reference in New Issue
Block a user