Throw an error if an attribute name contains a bracket

Fixes #4648
pull/4650/head
Daniel Imfeld 6 years ago
parent 7dcbc5173b
commit 1c3044486f

@ -378,6 +378,14 @@ export default class Element extends Node {
} }
} }
if (/[{}]/.test(name)) {
component.error(attribute, {
code: `illegal-attribute`,
message: `'${name}' is not a valid attribute name`,
});
}
if (name === 'slot') { if (name === 'slot') {
if (!attribute.is_static) { if (!attribute.is_static) {
component.error(attribute, { component.error(attribute, {

@ -0,0 +1,15 @@
[{
"code": "illegal-attribute",
"message": "'a}a' is not a valid attribute name",
"start": {
"line": 1,
"column": 3,
"character": 3
},
"end": {
"line": 1,
"column": 6,
"character": 6
},
"pos": 3
}]

@ -0,0 +1,16 @@
[
{
"code": "illegal-attribute",
"message": "'a{a' is not a valid attribute name",
"start": {
"line": 1,
"column": 3,
"character": 3
},
"end": {
"line": 1,
"column": 6,
"character": 6
},
"pos": 3
}]

@ -0,0 +1,15 @@
[{
"code": "illegal-attribute",
"message": "'}a' is not a valid attribute name",
"start": {
"line": 1,
"column": 3,
"character": 3
},
"end": {
"line": 1,
"column": 5,
"character": 5
},
"pos": 3
}]

@ -0,0 +1,15 @@
[{
"code": "illegal-attribute",
"message": "'a}' is not a valid attribute name",
"start": {
"line": 1,
"column": 3,
"character": 3
},
"end": {
"line": 1,
"column": 5,
"character": 5
},
"pos": 3
}]

@ -0,0 +1,15 @@
[{
"code": "illegal-attribute",
"message": "'}' is not a valid attribute name",
"start": {
"line": 1,
"column": 3,
"character": 3
},
"end": {
"line": 1,
"column": 4,
"character": 4
},
"pos": 3
}]
Loading…
Cancel
Save