// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = e => _ctx.a['b' + _ctx.c](e)
+ n0.$evtclick = _createInvoker(e => _ctx.a['b' + _ctx.c](e))
return n0
}"
`;
`;
exports[`v-on > dynamic arg 1`] = `
-"import { on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, _ctx.event, e => _ctx.handler(e), {
+ _on(n0, _ctx.event, _createInvoker(e => _ctx.handler(e)), {
effect: true
})
})
`;
exports[`v-on > dynamic arg with complex exp prefixing 1`] = `
-"import { on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, _ctx.event(_ctx.foo), e => _ctx.handler(e), {
+ _on(n0, _ctx.event(_ctx.foo), _createInvoker(e => _ctx.handler(e)), {
effect: true
})
})
`;
exports[`v-on > dynamic arg with prefixing 1`] = `
-"import { on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, _ctx.event, e => _ctx.handler(e), {
+ _on(n0, _ctx.event, _createInvoker(e => _ctx.handler(e)), {
effect: true
})
})
`;
exports[`v-on > event modifier 1`] = `
-"import { withModifiers as _withModifiers, on as _on, withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, on as _on, withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<a></a>")
const t1 = _template("<form></form>")
const t2 = _template("<div></div>")
const n19 = t3()
const n20 = t3()
const n21 = t3()
- n0.$evtclick = _withModifiers(_ctx.handleEvent, ["stop"])
- _on(n1, "submit", _withModifiers(_ctx.handleEvent, ["prevent"]))
- n2.$evtclick = _withModifiers(_ctx.handleEvent, ["stop","prevent"])
- n3.$evtclick = _withModifiers(_ctx.handleEvent, ["self"])
- _on(n4, "click", _ctx.handleEvent, {
+ n0.$evtclick = _createInvoker(_withModifiers(_ctx.handleEvent, ["stop"]))
+ _on(n1, "submit", _createInvoker(_withModifiers(_ctx.handleEvent, ["prevent"])))
+ n2.$evtclick = _createInvoker(_withModifiers(_ctx.handleEvent, ["stop","prevent"]))
+ n3.$evtclick = _createInvoker(_withModifiers(_ctx.handleEvent, ["self"]))
+ _on(n4, "click", _createInvoker(_ctx.handleEvent), {
capture: true
})
- _on(n5, "click", _ctx.handleEvent, {
+ _on(n5, "click", _createInvoker(_ctx.handleEvent), {
once: true
})
- _on(n6, "scroll", _ctx.handleEvent, {
+ _on(n6, "scroll", _createInvoker(_ctx.handleEvent), {
passive: true
})
- n7.$evtcontextmenu = _withModifiers(_ctx.handleEvent, ["right"])
- n8.$evtclick = _withModifiers(_ctx.handleEvent, ["left"])
- n9.$evtmouseup = _withModifiers(_ctx.handleEvent, ["middle"])
- n10.$evtcontextmenu = _withKeys(_withModifiers(_ctx.handleEvent, ["right"]), ["enter"])
- n11.$evtkeyup = _withKeys(_ctx.handleEvent, ["enter"])
- n12.$evtkeyup = _withKeys(_ctx.handleEvent, ["tab"])
- n13.$evtkeyup = _withKeys(_ctx.handleEvent, ["delete"])
- n14.$evtkeyup = _withKeys(_ctx.handleEvent, ["esc"])
- n15.$evtkeyup = _withKeys(_ctx.handleEvent, ["space"])
- n16.$evtkeyup = _withKeys(_ctx.handleEvent, ["up"])
- n17.$evtkeyup = _withKeys(_ctx.handleEvent, ["down"])
- n18.$evtkeyup = _withKeys(_ctx.handleEvent, ["left"])
- n19.$evtkeyup = _withModifiers(e => _ctx.submit(e), ["middle"])
- n20.$evtkeyup = _withModifiers(e => _ctx.submit(e), ["middle","self"])
- n21.$evtkeyup = _withKeys(_withModifiers(_ctx.handleEvent, ["self"]), ["enter"])
+ n7.$evtcontextmenu = _createInvoker(_withModifiers(_ctx.handleEvent, ["right"]))
+ n8.$evtclick = _createInvoker(_withModifiers(_ctx.handleEvent, ["left"]))
+ n9.$evtmouseup = _createInvoker(_withModifiers(_ctx.handleEvent, ["middle"]))
+ n10.$evtcontextmenu = _createInvoker(_withKeys(_withModifiers(_ctx.handleEvent, ["right"]), ["enter"]))
+ n11.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["enter"]))
+ n12.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["tab"]))
+ n13.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["delete"]))
+ n14.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["esc"]))
+ n15.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["space"]))
+ n16.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["up"]))
+ n17.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["down"]))
+ n18.$evtkeyup = _createInvoker(_withKeys(_ctx.handleEvent, ["left"]))
+ n19.$evtkeyup = _createInvoker(_withModifiers(e => _ctx.submit(e), ["middle"]))
+ n20.$evtkeyup = _createInvoker(_withModifiers(e => _ctx.submit(e), ["middle","self"]))
+ n21.$evtkeyup = _createInvoker(_withKeys(_withModifiers(_ctx.handleEvent, ["self"]), ["enter"]))
return [n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21]
}"
`;
exports[`v-on > expression with type 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx, $props, $emit, $attrs, $slots) {
const n0 = t0()
- n0.$evtclick = e => _ctx.handleClick(e)
+ n0.$evtclick = _createInvoker(e => _ctx.handleClick(e))
return n0
}"
`;
exports[`v-on > function expression w/ prefixIdentifiers: true 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = e => _ctx.foo(e)
+ n0.$evtclick = _createInvoker(e => _ctx.foo(e))
return n0
}"
`;
exports[`v-on > inline statement w/ prefixIdentifiers: true 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = $event => (_ctx.foo($event))
+ n0.$evtclick = _createInvoker($event => (_ctx.foo($event)))
return n0
}"
`;
exports[`v-on > multiple inline statements w/ prefixIdentifiers: true 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = $event => {_ctx.foo($event);_ctx.bar()}
+ n0.$evtclick = _createInvoker($event => {_ctx.foo($event);_ctx.bar()})
return n0
}"
`;
exports[`v-on > should NOT add a prefix to $event if the expression is a function expression 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = $event => {_ctx.i++;_ctx.foo($event)}
+ n0.$evtclick = _createInvoker($event => {_ctx.i++;_ctx.foo($event)})
return n0
}"
`;
exports[`v-on > should NOT wrap as function if expression is already function expression (with Typescript) 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = (e: any): any => _ctx.foo(e)
+ n0.$evtclick = _createInvoker((e: any): any => _ctx.foo(e))
return n0
}"
`;
exports[`v-on > should NOT wrap as function if expression is already function expression (with newlines) 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick =
+ n0.$evtclick = _createInvoker(
$event => {
_ctx.foo($event)
}
-
+ )
return n0
}"
`;
exports[`v-on > should NOT wrap as function if expression is already function expression 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = $event => _ctx.foo($event)
+ n0.$evtclick = _createInvoker($event => _ctx.foo($event))
return n0
}"
`;
exports[`v-on > should NOT wrap as function if expression is complex member expression 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = e => _ctx.a['b' + _ctx.c](e)
+ n0.$evtclick = _createInvoker(e => _ctx.a['b' + _ctx.c](e))
return n0
}"
`;
exports[`v-on > should delegate event 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = e => _ctx.test(e)
+ n0.$evtclick = _createInvoker(e => _ctx.test(e))
return n0
}"
`;
exports[`v-on > should handle multi-line statement 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = () => {
+ n0.$evtclick = _createInvoker(() => {
_ctx.foo();
_ctx.bar()
-}
+})
return n0
}"
`;
exports[`v-on > should handle multiple inline statement 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = () => {_ctx.foo();_ctx.bar()}
+ n0.$evtclick = _createInvoker(() => {_ctx.foo();_ctx.bar()})
return n0
}"
`;
exports[`v-on > should not prefix member expression 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = e => _ctx.foo.bar(e)
+ n0.$evtclick = _createInvoker(e => _ctx.foo.bar(e))
return n0
}"
`;
exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
-"import { withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("keyup")
export function render(_ctx) {
const n0 = t0()
- n0.$evtkeyup = _withModifiers(e => _ctx.test(e), ["exact"])
+ n0.$evtkeyup = _createInvoker(_withModifiers(e => _ctx.test(e), ["exact"]))
return n0
}"
`;
exports[`v-on > should support multiple events and modifiers options w/ prefixIdentifiers: true 1`] = `
-"import { withModifiers as _withModifiers, withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click", "keyup")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = _withModifiers(e => _ctx.test(e), ["stop"])
- n0.$evtkeyup = _withKeys(e => _ctx.test(e), ["enter"])
+ n0.$evtclick = _createInvoker(_withModifiers(e => _ctx.test(e), ["stop"]))
+ n0.$evtkeyup = _createInvoker(_withKeys(e => _ctx.test(e), ["enter"]))
return n0
}"
`;
exports[`v-on > should support multiple modifiers and event options w/ prefixIdentifiers: true 1`] = `
-"import { withModifiers as _withModifiers, on as _on, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, on as _on, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
- _on(n0, "click", _withModifiers(e => _ctx.test(e), ["stop","prevent"]), {
+ _on(n0, "click", _createInvoker(_withModifiers(e => _ctx.test(e), ["stop","prevent"])), {
capture: true,
once: true
})
`;
exports[`v-on > should transform click.middle 1`] = `
-"import { withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("mouseup")
export function render(_ctx) {
const n0 = t0()
- n0.$evtmouseup = _withModifiers(e => _ctx.test(e), ["middle"])
+ n0.$evtmouseup = _createInvoker(_withModifiers(e => _ctx.test(e), ["middle"]))
return n0
}"
`;
exports[`v-on > should transform click.middle 2`] = `
-"import { withModifiers as _withModifiers, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), _withModifiers(e => _ctx.test(e), ["middle"]), {
+ _on(n0, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), _createInvoker(_withModifiers(e => _ctx.test(e), ["middle"])), {
effect: true
})
})
`;
exports[`v-on > should transform click.right 1`] = `
-"import { withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("contextmenu")
export function render(_ctx) {
const n0 = t0()
- n0.$evtcontextmenu = _withModifiers(e => _ctx.test(e), ["right"])
+ n0.$evtcontextmenu = _createInvoker(_withModifiers(e => _ctx.test(e), ["right"]))
return n0
}"
`;
exports[`v-on > should transform click.right 2`] = `
-"import { withModifiers as _withModifiers, withKeys as _withKeys, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, withKeys as _withKeys, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), _withKeys(_withModifiers(e => _ctx.test(e), ["right"]), ["right"]), {
+ _on(n0, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), _createInvoker(_withKeys(_withModifiers(e => _ctx.test(e), ["right"]), ["right"])), {
effect: true
})
})
`;
exports[`v-on > should use delegate helper when have multiple events of same name 1`] = `
-"import { delegate as _delegate, withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegate as _delegate, withModifiers as _withModifiers, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- _delegate(n0, "click", e => _ctx.test(e))
- _delegate(n0, "click", _withModifiers(e => _ctx.test(e), ["stop"]))
+ _delegate(n0, "click", _createInvoker(e => _ctx.test(e)))
+ _delegate(n0, "click", _createInvoker(_withModifiers(e => _ctx.test(e), ["stop"])))
return n0
}"
`;
exports[`v-on > should wrap as function if expression is inline statement 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- n0.$evtclick = () => (_ctx.i++)
+ n0.$evtclick = _createInvoker(() => (_ctx.i++))
return n0
}"
`;
exports[`v-on > should wrap both for dynamic key event w/ left/right modifiers 1`] = `
-"import { withModifiers as _withModifiers, withKeys as _withKeys, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, withKeys as _withKeys, on as _on, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
_renderEffect(() => {
- _on(n0, _ctx.e, _withKeys(_withModifiers(e => _ctx.test(e), ["left"]), ["left"]), {
+ _on(n0, _ctx.e, _createInvoker(_withKeys(_withModifiers(e => _ctx.test(e), ["left"]), ["left"])), {
effect: true
})
})
const n0 = t0()
const n1 = t0()
const n2 = t0()
- n0.$evtclick = () => (x.value=_unref(y))
- n1.$evtclick = () => (x.value++)
- n2.$evtclick = () => ({ x: x.value } = _unref(y))
+ n0.$evtclick = _createInvoker(() => (x.value=_unref(y)))
+ n1.$evtclick = _createInvoker(() => (x.value++))
+ n2.$evtclick = _createInvoker(() => ({ x: x.value } = _unref(y)))
return [n0, n1, n2]
"
`;
exports[`v-on > should wrap keys guard for keyboard events or dynamic events 1`] = `
-"import { withModifiers as _withModifiers, withKeys as _withKeys, on as _on, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withModifiers as _withModifiers, withKeys as _withKeys, on as _on, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
export function render(_ctx) {
const n0 = t0()
- _on(n0, "keydown", _withKeys(_withModifiers(e => _ctx.test(e), ["stop","ctrl"]), ["a"]), {
+ _on(n0, "keydown", _createInvoker(_withKeys(_withModifiers(e => _ctx.test(e), ["stop","ctrl"]), ["a"])), {
capture: true
})
return n0
`;
exports[`v-on > should wrap keys guard for static key event w/ left/right modifiers 1`] = `
-"import { withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, withKeys as _withKeys, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("keyup")
export function render(_ctx) {
const n0 = t0()
- n0.$evtkeyup = _withKeys(e => _ctx.test(e), ["left"])
+ n0.$evtkeyup = _createInvoker(_withKeys(e => _ctx.test(e), ["left"]))
return n0
}"
`;
exports[`v-on > simple expression 1`] = `
-"import { delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div></div>", true)
_delegateEvents("click")
export function render(_ctx, $props, $emit, $attrs, $slots) {
const n0 = t0()
- n0.$evtclick = _ctx.handleClick
+ n0.$evtclick = _createInvoker(_ctx.handleClick)
return n0
}"
`;
delegate: true,
},
])
- expect(code).contains(`n0.$evtclick = () => (_ctx.i++)`)
+ expect(code).contains(`n0.$evtclick = _createInvoker(() => (_ctx.i++))`)
})
test('should wrap in unref if identifier is setup-maybe-ref w/ inline: true', () => {
)
expect(code).matchSnapshot()
expect(helpers).contains('unref')
- expect(code).contains(`n0.$evtclick = () => (x.value=_unref(y))`)
- expect(code).contains(`n1.$evtclick = () => (x.value++)`)
- expect(code).contains(`n2.$evtclick = () => ({ x: x.value } = _unref(y))`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker(() => (x.value=_unref(y)))`,
+ )
+ expect(code).contains(`n1.$evtclick = _createInvoker(() => (x.value++))`)
+ expect(code).contains(
+ `n2.$evtclick = _createInvoker(() => ({ x: x.value } = _unref(y)))`,
+ )
})
test('should handle multiple inline statement', () => {
// should wrap with `{` for multiple statements
// in this case the return value is discarded and the behavior is
// consistent with 2.x
- expect(code).contains(`n0.$evtclick = () => {_ctx.foo();_ctx.bar()}`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker(() => {_ctx.foo();_ctx.bar()})`,
+ )
})
test('should handle multi-line statement', () => {
// should wrap with `{` for multiple statements
// in this case the return value is discarded and the behavior is
// consistent with 2.x
- expect(code).contains(`n0.$evtclick = () => {\n_ctx.foo();\n_ctx.bar()\n}`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker(() => {\n_ctx.foo();\n_ctx.bar()\n})`,
+ )
})
test('inline statement w/ prefixIdentifiers: true', () => {
},
])
// should NOT prefix $event
- expect(code).contains(`n0.$evtclick = $event => (_ctx.foo($event))`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker($event => (_ctx.foo($event)))`,
+ )
})
test('multiple inline statements w/ prefixIdentifiers: true', () => {
])
// should NOT prefix $event
expect(code).contains(
- `n0.$evtclick = $event => {_ctx.foo($event);_ctx.bar()}`,
+ `n0.$evtclick = _createInvoker($event => {_ctx.foo($event);_ctx.bar()})`,
)
})
value: { content: '$event => foo($event)' },
},
])
- expect(code).contains(`n0.$evtclick = $event => _ctx.foo($event)`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker($event => _ctx.foo($event))`,
+ )
})
test('should NOT wrap as function if expression is already function expression (with Typescript)', () => {
value: { content: '(e: any): any => foo(e)' },
},
])
- expect(code).contains(`n0.$evtclick = (e: any): any => _ctx.foo(e)`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker((e: any): any => _ctx.foo(e))`,
+ )
})
test('should NOT wrap as function if expression is already function expression (with newlines)', () => {
])
expect(code).matchSnapshot()
- expect(code).contains(`n0.$evtclick = e => _ctx.a['b' + _ctx.c](e)`)
+ expect(code).contains(
+ `n0.$evtclick = _createInvoker(e => _ctx.a['b' + _ctx.c](e))`,
+ )
})
test('function expression w/ prefixIdentifiers: true', () => {
value: { content: `e => foo(e)` },
},
])
- expect(code).contains(`n0.$evtclick = e => _ctx.foo(e)`)
+ expect(code).contains(`n0.$evtclick = _createInvoker(e => _ctx.foo(e))`)
})
test('should error if no expression AND no modifier', () => {
},
])
expect(code).contains(
- `_on(n0, "click", _withModifiers(e => _ctx.test(e), ["stop","prevent"]), {
+ `_on(n0, "click", _createInvoker(_withModifiers(e => _ctx.test(e), ["stop","prevent"])), {
capture: true,
once: true
})`,
expect(code).matchSnapshot()
expect(code).contains(
- `n0.$evtclick = _withModifiers(e => _ctx.test(e), ["stop"])
- n0.$evtkeyup = _withKeys(e => _ctx.test(e), ["enter"])`,
+ `n0.$evtclick = _createInvoker(_withModifiers(e => _ctx.test(e), ["stop"]))
+ n0.$evtkeyup = _createInvoker(_withKeys(e => _ctx.test(e), ["enter"]))`,
)
})
})
expect(code).matchSnapshot()
- expect(code).contains(`n0.$evtclick = e => _ctx.foo.bar(e)`)
+ expect(code).contains(`n0.$evtclick = _createInvoker(e => _ctx.foo.bar(e))`)
})
test('should delegate event', () => {
)
expect(helpers).contains('delegate')
expect(code).toMatchSnapshot()
- expect(code).contains('_delegate(n0, "click", e => _ctx.test(e))')
expect(code).contains(
- '_delegate(n0, "click", _withModifiers(e => _ctx.test(e), ["stop"]))',
+ '_delegate(n0, "click", _createInvoker(e => _ctx.test(e)))',
+ )
+ expect(code).contains(
+ '_delegate(n0, "click", _createInvoker(_withModifiers(e => _ctx.test(e), ["stop"])))',
)
})
},
)
expect(code).matchSnapshot()
- expect(code).include('n0.$evtclick = e => _ctx.handleClick(e)')
+ expect(code).include(
+ 'n0.$evtclick = _createInvoker(e => _ctx.handleClick(e))',
+ )
})
test('component event with special characters', () => {