fix: allow member access on directives

pull/9462/head
paoloricciuti 3 years ago
parent f5101c0d8c
commit 318240e46a

@ -467,7 +467,16 @@ function read_attribute(parser, unique_names) {
}
if (type) {
const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|');
const [base_directive_name, ...modifiers] = name.slice(colon_index + 1).split('|');
// this allow for accessing members of an object
const splitted_directive = base_directive_name.split('.');
let directive_name = splitted_directive.shift() ?? '';
for (let new_piece of splitted_directive) {
directive_name += `['${new_piece}']`;
}
if (directive_name === '') {
error(start + colon_index + 1, 'empty-directive-name', type);

@ -0,0 +1,26 @@
{
"html": {
"type": "Fragment",
"start": 0,
"end": 25,
"children": [
{
"type": "Element",
"start": 0,
"end": 25,
"name": "input",
"attributes": [
{
"start": 7,
"end": 24,
"type": "Action",
"name": "nested['action']",
"modifiers": [],
"expression": null
}
],
"children": []
}
]
}
}
Loading…
Cancel
Save