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 #1721.

Fixes #5198.
pull/15983/head
Joe Schafer 4 months ago
parent 50de8c5317
commit 5b736069f5

@ -0,0 +1,5 @@
---
'svelte': patch
---
Allow attributes on the title element.

@ -1082,12 +1082,6 @@ Expected a valid element or component name. Components must have a valid variabl
A `<textarea>` can have either a value attribute or (equivalently) child content, but not both
```
### title_illegal_attribute
```
`<title>` cannot have attributes nor directives
```
### title_invalid_content
```

@ -398,10 +398,6 @@ See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-ele
> A `<textarea>` can have either a value attribute or (equivalently) child content, but not both
## title_illegal_attribute
> `<title>` cannot have attributes nor directives
## title_invalid_content
> `<title>` can only contain text and {tags}

@ -1573,15 +1573,6 @@ export function textarea_invalid_content(node) {
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`);
}
/**
* `<title>` cannot have attributes nor directives
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function title_illegal_attribute(node) {
e(node, 'title_illegal_attribute', `\`<title>\` cannot have attributes nor directives\nhttps://svelte.dev/e/title_illegal_attribute`);
}
/**
* `<title>` can only contain text and {tags}
* @param {null | number | NodeLike} node

@ -7,10 +7,6 @@ import * as e from '../../../errors.js';
* @param {Context} context
*/
export function TitleElement(node, context) {
for (const attribute of node.attributes) {
e.title_illegal_attribute(attribute);
}
for (const child of node.fragment.nodes) {
if (child.type !== 'Text' && child.type !== 'ExpressionTag') {
e.title_invalid_content(child);

@ -1,14 +0,0 @@
[
{
"code": "title_illegal_attribute",
"message": "`<title>` cannot have attributes nor directives",
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 25
}
}
]
Loading…
Cancel
Save