ensure onrender and onteardown are not arrow function expressions

pull/184/head
Rich-Harris 8 years ago
parent a6c648b086
commit 017b67aa38

@ -1,3 +1,9 @@
export default function onrender () { import usesThisOrArguments from '../utils/usesThisOrArguments.js';
export default function onrender ( validator, prop ) {
if ( prop.value.type === 'ArrowFunctionExpression' ) {
if ( usesThisOrArguments( prop.value.body ) ) {
validator.error( `'onrender' should be a function expression, not an arrow function expression`, prop.start );
}
}
} }

@ -1,3 +1,9 @@
export default function onteardown () { import usesThisOrArguments from '../utils/usesThisOrArguments.js';
export default function onteardown ( validator, prop ) {
if ( prop.value.type === 'ArrowFunctionExpression' ) {
if ( usesThisOrArguments( prop.value.body ) ) {
validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start );
}
}
} }

@ -0,0 +1,5 @@
<script>
export default {
onrender: () => console.log( 'rendering' )
};
</script>

@ -0,0 +1,8 @@
[{
"message": "'onrender' should be a function expression, not an arrow function expression",
"pos": 29,
"loc": {
"line": 3,
"column": 2
}
}]

@ -0,0 +1,7 @@
<script>
export default {
onrender: () => {
this.set({ a: 1 });
}
};
</script>

@ -0,0 +1,5 @@
<script>
export default {
onteardown: () => console.log( 'tearing down' )
};
</script>

@ -0,0 +1,8 @@
[{
"message": "'onteardown' should be a function expression, not an arrow function expression",
"pos": 29,
"loc": {
"line": 3,
"column": 2
}
}]

@ -0,0 +1,7 @@
<script>
export default {
onteardown: () => {
this.set({ a: 1 });
}
};
</script>
Loading…
Cancel
Save