Skip to content

Commit a560b37

Browse files
committed
fix: allow attributes on the title element
The spec states the title element supports global attributes. https://html.spec.whatwg.org/#the-title-element Reverts the title attribute validation introduced in sveltejs#1721. Fixes sveltejs#5198.
1 parent 50de8c5 commit a560b37

File tree

5 files changed

+1
-38
lines changed

5 files changed

+1
-38
lines changed

documentation/docs/98-reference/.generated/compile-errors.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,12 +1082,6 @@ Expected a valid element or component name. Components must have a valid variabl
10821082
A `<textarea>` can have either a value attribute or (equivalently) child content, but not both
10831083
```
10841084

1085-
### title_illegal_attribute
1086-
1087-
```
1088-
`<title>` cannot have attributes nor directives
1089-
```
1090-
10911085
### title_invalid_content
10921086

10931087
```

packages/svelte/messages/compile-errors/template.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,6 @@ See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-ele
398398

399399
> A `<textarea>` can have either a value attribute or (equivalently) child content, but not both
400400
401-
## title_illegal_attribute
402-
403-
> `<title>` cannot have attributes nor directives
404-
405401
## title_invalid_content
406402

407403
> `<title>` can only contain text and {tags}

packages/svelte/src/compiler/errors.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,15 +1573,6 @@ export function textarea_invalid_content(node) {
15731573
e(node, 'textarea_invalid_content', `A \`<textarea>\` can have either a value attribute or (equivalently) child content, but not both\nhttps://svelte.dev/e/textarea_invalid_content`);
15741574
}
15751575

1576-
/**
1577-
* `<title>` cannot have attributes nor directives
1578-
* @param {null | number | NodeLike} node
1579-
* @returns {never}
1580-
*/
1581-
export function title_illegal_attribute(node) {
1582-
e(node, 'title_illegal_attribute', `\`<title>\` cannot have attributes nor directives\nhttps://svelte.dev/e/title_illegal_attribute`);
1583-
}
1584-
15851576
/**
15861577
* `<title>` can only contain text and {tags}
15871578
* @param {null | number | NodeLike} node
@@ -1647,4 +1638,4 @@ export function unterminated_string_constant(node) {
16471638
*/
16481639
export function void_element_invalid_content(node) {
16491640
e(node, 'void_element_invalid_content', `Void elements cannot have children or closing tags\nhttps://svelte.dev/e/void_element_invalid_content`);
1650-
}
1641+
}

packages/svelte/src/compiler/phases/2-analyze/visitors/TitleElement.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import * as e from '../../../errors.js';
77
* @param {Context} context
88
*/
99
export function TitleElement(node, context) {
10-
for (const attribute of node.attributes) {
11-
e.title_illegal_attribute(attribute);
12-
}
13-
1410
for (const child of node.fragment.nodes) {
1511
if (child.type !== 'Text' && child.type !== 'ExpressionTag') {
1612
e.title_invalid_content(child);

packages/svelte/tests/validator/samples/title-no-attributes/errors.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)