Skip to content

Commit

Permalink
Merge pull request #793 from sveltejs/gh-791
Browse files Browse the repository at this point in the history
error if component has transition
  • Loading branch information
Rich-Harris authored Aug 29, 2017
2 parents 56677a2 + cb92f30 commit 502f6b6
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 502f6b6

Please sign in to comment.