component shorthand events

pull/1864/head
Rich Harris 7 years ago
parent 35412a9a92
commit 58e532fc08

@ -113,7 +113,7 @@ export default function dom(
const superclass = component.alias(options.dev ? '$$ComponentDev' : '$$Component');
if (options.dev && !options.hydratable) {
block.builders.hydrate.addLine(
block.builders.claim.addLine(
'throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");'
);
}

@ -54,7 +54,9 @@ export default class InlineComponentWrapper extends Wrapper {
});
this.node.handlers.forEach(handler => {
if (handler.expression) {
block.addDependencies(handler.expression.dependencies);
}
});
this.var = (
@ -260,7 +262,7 @@ export default class InlineComponentWrapper extends Wrapper {
`${handler.name.replace(/[^a-zA-Z0-9_$]/g, '_')}_handler`
);
if (handler.expression.contextual_dependencies.size > 0) {
if (handler.expression && handler.expression.contextual_dependencies.size > 0) {
block.maintainContext = true; // TODO is there a better place to put this?
const deps = Array.from(handler.expression.contextual_dependencies);

@ -117,4 +117,11 @@ export class $$ComponentDev extends $$Component {
super(options);
}
$destroy() {
super.$destroy();
this.$$destroy = () => {
console.warn(`Component was already destroyed`);
};
}
}

@ -9,7 +9,7 @@ export default {
let answer;
component.$on('foo', event => {
answer = event.answer;
answer = event.detail.answer;
});
button.dispatchEvent(event);

@ -1,15 +0,0 @@
export default {
test(assert, component) {
let count = 0;
const expected = { x: 1 };
component.$on('foo', data => {
assert.equal(data, expected);
count += 1;
});
component.fire('foo', expected);
assert.equal(count, 1);
}
};
Loading…
Cancel
Save