Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class HeadOnlyElementsVisitor extends BaseRuleVisitor {
if (!this.insideBody) return
if (!isHeadOnlyTag(tagName)) return
if (tagName === "title" && this.insideSVG) return
if (tagName === "style" && this.insideSVG) return
if (tagName === "meta" && this.hasItempropAttribute(node)) return

this.addOffense(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,26 @@ describe("html-head-only-elements", () => {
`)
})

test("allows style element inside SVG", () => {
expectNoOffenses(dedent`
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hi</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29">
<defs>
<style>
.cls-1 {fill:none;stroke:#fff}
</style>
</defs>
</svg>
</body>
</html>
`)
})

test("still fails for other head-only elements inside SVG", () => {
expectError("Element `<meta>` must be placed inside the `<head>` tag.")
expectError("Element `<link>` must be placed inside the `<head>` tag.")
Expand Down
Loading