added cssText check (#23)

* added cssText check

* added testing
This commit is contained in:
Filip Slatinac
2019-11-27 01:17:00 -05:00
committed by yz-yu
parent acb53f2ef1
commit f1cae2f68c
3 changed files with 24 additions and 23 deletions

View File

@@ -146,11 +146,11 @@ export function transformAttribute(
value: string, value: string,
): string { ): string {
// relative path in attribute // relative path in attribute
if (name === 'src' || name === 'href') { if (name === 'src' || (name === 'href' && value)) {
return absoluteToDoc(doc, value); return absoluteToDoc(doc, value);
} else if (name === 'srcset') { } else if (name === 'srcset' && value) {
return getAbsoluteSrcsetString(doc, value); return getAbsoluteSrcsetString(doc, value);
} else if (name === 'style') { } else if (name === 'style' && value) {
return absoluteToStylesheet(value, location.href); return absoluteToStylesheet(value, location.href);
} else { } else {
return value; return value;

View File

@@ -75,12 +75,14 @@ exports[`[html file]: block-element.html 1`] = `
exports[`[html file]: cors-style-sheet.html 1`] = ` exports[`[html file]: cors-style-sheet.html 1`] = `
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head> "<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
<meta charset=\\"UTF-8\\" /> <meta charset=\\"UTF-8\\" />
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" /> <meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" /> <meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
<title>with style sheet</title> <title>with style sheet</title>
<link rel=\\"stylesheet\\" href=\\"https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css\\" /> <link rel=\\"stylesheet\\" href=\\"https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css\\" />
</head><body></body></html>" <link rel=\\"stylesheet\\" href=\\"\\" />
</head>
<body></body></html>"
`; `;
exports[`[html file]: dynamic-stylesheet.html 1`] = ` exports[`[html file]: dynamic-stylesheet.html 1`] = `

View File

@@ -1,16 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head> <meta charset="UTF-8" />
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>with style sheet</title>
<title>with style sheet</title> <link
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css"> rel="stylesheet"
</head> href="https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css"
/>
<body> <link rel="stylesheet" href />
</head>
</body> <body></body>
</html>
</html>