From 13e3d755dab97d91a7b2a95b39a8e3a6961593dd Mon Sep 17 00:00:00 2001 From: pushkine Date: Mon, 25 Jan 2021 21:55:12 +0100 Subject: [PATCH] allow duplicates of the same action on an element (#5875) --- src/compiler/parse/state/tag.ts | 2 +- .../samples/action-duplicate/input.svelte | 1 + .../samples/action-duplicate/output.json | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/parser/samples/action-duplicate/input.svelte create mode 100644 test/parser/samples/action-duplicate/output.json diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index efeb9433bc..696a47b649 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -376,7 +376,7 @@ function read_attribute(parser: Parser, unique_names: Set) { if (type === 'Binding' && directive_name !== 'this') { check_unique(directive_name); - } else if (type !== 'EventHandler') { + } else if (type !== 'EventHandler' && type !== 'Action') { check_unique(name); } diff --git a/test/parser/samples/action-duplicate/input.svelte b/test/parser/samples/action-duplicate/input.svelte new file mode 100644 index 0000000000..11b2515483 --- /dev/null +++ b/test/parser/samples/action-duplicate/input.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/action-duplicate/output.json b/test/parser/samples/action-duplicate/output.json new file mode 100644 index 0000000000..30469ceb48 --- /dev/null +++ b/test/parser/samples/action-duplicate/output.json @@ -0,0 +1,34 @@ +{ + "html": { + "start": 0, + "end": 35, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 35, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 20, + "type": "Action", + "name": "autofocus", + "modifiers": [], + "expression": null + }, + { + "start": 21, + "end": 34, + "type": "Action", + "name": "autofocus", + "modifiers": [], + "expression": null + } + ], + "children": [] + } + ] + } +} \ No newline at end of file