Lint and format src/compiler/compile/render_dom/wrappers/Element/EventHandler.js

pull/8569/head
Simon Holthausen 3 years ago
parent 87420085e1
commit 920f6383c8

@ -3,7 +3,6 @@ const TRUE = x `true`;
const FALSE = x`false`; const FALSE = x`false`;
/** */ /** */
export default class EventHandlerWrapper { export default class EventHandlerWrapper {
/** @type {import('../../../nodes/EventHandler.js').default} */ /** @type {import('../../../nodes/EventHandler.js').default} */
node; node;
@ -45,27 +44,25 @@ export default class EventHandlerWrapper {
*/ */
render(block, target) { render(block, target) {
let snippet = this.get_snippet(block); let snippet = this.get_snippet(block);
if (this.node.modifiers.has('preventDefault')) if (this.node.modifiers.has('preventDefault')) snippet = x`@prevent_default(${snippet})`;
snippet = x `@prevent_default(${snippet})`; if (this.node.modifiers.has('stopPropagation')) snippet = x`@stop_propagation(${snippet})`;
if (this.node.modifiers.has('stopPropagation'))
snippet = x `@stop_propagation(${snippet})`;
if (this.node.modifiers.has('stopImmediatePropagation')) if (this.node.modifiers.has('stopImmediatePropagation'))
snippet = x`@stop_immediate_propagation(${snippet})`; snippet = x`@stop_immediate_propagation(${snippet})`;
if (this.node.modifiers.has('self')) if (this.node.modifiers.has('self')) snippet = x`@self(${snippet})`;
snippet = x `@self(${snippet})`; if (this.node.modifiers.has('trusted')) snippet = x`@trusted(${snippet})`;
if (this.node.modifiers.has('trusted'))
snippet = x `@trusted(${snippet})`;
const args = []; const args = [];
const opts = ['nonpassive', 'passive', 'once', 'capture'].filter((mod) => this.node.modifiers.has(mod)); const opts = ['nonpassive', 'passive', 'once', 'capture'].filter((mod) =>
this.node.modifiers.has(mod)
);
if (opts.length) { if (opts.length) {
if (opts.length === 1 && opts[0] === 'capture') { if (opts.length === 1 && opts[0] === 'capture') {
args.push(TRUE); args.push(TRUE);
} else {
args.push(
x`{ ${opts.map((opt) => (opt === 'nonpassive' ? p`passive: false` : p`${opt}: true`))} }`
);
} }
else { } else if (block.renderer.options.dev) {
args.push(x `{ ${opts.map((opt) => (opt === 'nonpassive' ? p `passive: false` : p `${opt}: true`))} }`);
}
}
else if (block.renderer.options.dev) {
args.push(FALSE); args.push(FALSE);
} }
if (block.renderer.options.dev) { if (block.renderer.options.dev) {
@ -76,7 +73,3 @@ export default class EventHandlerWrapper {
block.event_listeners.push(x`@listen(${target}, "${this.node.name}", ${snippet}, ${args})`); block.event_listeners.push(x`@listen(${target}, "${this.node.name}", ${snippet}, ${args})`);
} }
} }

Loading…
Cancel
Save