From cb92f3028e360b2ce745a1b879a1c8e42882e29d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 29 Aug 2017 08:09:41 -0400 Subject: [PATCH] error if component has transition (fixes #791) --- src/validate/html/validateElement.ts | 4 ++++ .../samples/transition-on-component/errors.json | 8 ++++++++ .../samples/transition-on-component/input.html | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/validator/samples/transition-on-component/errors.json create mode 100644 test/validator/samples/transition-on-component/input.html diff --git a/src/validate/html/validateElement.ts b/src/validate/html/validateElement.ts index ce412382c651..3641280f191f 100644 --- a/src/validate/html/validateElement.ts +++ b/src/validate/html/validateElement.ts @@ -116,6 +116,10 @@ export default function validateElement(validator: Validator, node: Node, refs: } else if (attribute.type === 'EventHandler') { validateEventHandler(validator, attribute, refCallees); } else if (attribute.type === 'Transition') { + if (isComponent) { + validator.error(`Transitions can only be applied to DOM elements, not components`, attribute.start); + } + const bidi = attribute.intro && attribute.outro; if (hasTransition) { diff --git a/test/validator/samples/transition-on-component/errors.json b/test/validator/samples/transition-on-component/errors.json new file mode 100644 index 000000000000..d18125c8c297 --- /dev/null +++ b/test/validator/samples/transition-on-component/errors.json @@ -0,0 +1,8 @@ +[{ + "message": "Transitions can only be applied to DOM elements, not components", + "loc": { + "line": 1, + "column": 8 + }, + "pos": 8 +}] \ No newline at end of file diff --git a/test/validator/samples/transition-on-component/input.html b/test/validator/samples/transition-on-component/input.html new file mode 100644 index 000000000000..c5ada08ece88 --- /dev/null +++ b/test/validator/samples/transition-on-component/input.html @@ -0,0 +1,15 @@ + + + \ No newline at end of file