Add an error for a slot name starts with a digit

pull/2304/head
Mikhail Korepanov 6 years ago
parent 079ce998ef
commit a27a43076e

@ -34,6 +34,13 @@ export default class Slot extends Element {
message: `default is a reserved word — it cannot be used as a slot name`
});
}
if (/^[0-9]/.test(slot_name)) {
component.error(attr, {
code: `invalid-slot-name`,
message: `<slot> name cannot start with a digit`
});
}
}
// TODO should duplicate slots be disallowed? Feels like it's more likely to be a
@ -70,4 +77,4 @@ export default class Slot extends Element {
return null;
}
}
}

@ -0,0 +1,15 @@
[{
"code": "invalid-slot-name",
"message": "<slot> name cannot start with a digit",
"start": {
"line": 2,
"column": 7,
"character": 13
},
"end": {
"line": 2,
"column": 21,
"character": 27
},
"pos": 13
}]
Loading…
Cancel
Save