Skip to content

Commit

Permalink
error if component has transition (fixes #791)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 29, 2017
1 parent 87ef5ff commit cb92f30
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/validate/html/validateElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions test/validator/samples/transition-on-component/errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"message": "Transitions can only be applied to DOM elements, not components",
"loc": {
"line": 1,
"column": 8
},
"pos": 8
}]
15 changes: 15 additions & 0 deletions test/validator/samples/transition-on-component/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Widget in:foo/>

<script>
import Widget from './Widget.html';

export default {
components: {
Widget
},

transitions: {
foo() {}
}
};
</script>

0 comments on commit cb92f30

Please sign in to comment.