Skip to content

feat: compound expression for v-on #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c96ac00
feat(v-on): should wrap as function if expression is inline statement
LittleSound Dec 12, 2023
4577802
test: dynamic arg with complex exp prefixing
LittleSound Dec 12, 2023
13d530d
feat(v-on): should handle multiple inline statement
LittleSound Dec 12, 2023
488d39e
test: should handle multi-line statement
LittleSound Dec 12, 2023
179b9e5
feat(v-on): inline statement with $event
LittleSound Dec 12, 2023
1803391
test(v-on): multiple inline statements w/ prefixIdentifiers: true
LittleSound Dec 12, 2023
b9d1c9e
feat(v-on): should NOT wrap as function if expression is already func…
LittleSound Dec 12, 2023
fbb89ad
test: should NOT wrap as function if expression is already function e…
LittleSound Dec 12, 2023
fad465b
test: should NOT wrap as function if expression is already function e…
LittleSound Dec 12, 2023
c1607db
test: should NOT wrap as function if expression is complex member exp…
LittleSound Dec 12, 2023
64328c0
test: organize test code
LittleSound Dec 12, 2023
812d053
test(v-on): should wrap both for dynamic key event w/ left/right modi…
LittleSound Dec 12, 2023
51adcd5
feat(v-on): function expression with params
LittleSound Dec 12, 2023
71985e3
refactor(v-on): function expression with params
LittleSound Dec 12, 2023
ea90bb1
feat(runtime-vapor): add set proxy to instance.proxy
LittleSound Dec 13, 2023
a0600c7
feat(runtime-vapor): add cleanup to effect
LittleSound Dec 13, 2023
e8b5eac
test: update snapshots
LittleSound Dec 13, 2023
43a60e9
fix(v-on): should NOT add a prefix to $event if the expression is a f…
LittleSound Dec 14, 2023
24cffb3
chore: organize code
LittleSound Dec 15, 2023
fc0fc39
Merge branch 'main' of https://github.com/vuejs/core-vapor into feat/…
LittleSound Dec 15, 2023
9972142
refactor: effect cleanup
LittleSound Dec 15, 2023
8ef5ac9
chore: organize the playground
LittleSound Dec 15, 2023
993102d
chore: optimize code
LittleSound Dec 15, 2023
d58a3b2
feat: add cleanup to onStop
LittleSound Dec 15, 2023
ec0eb33
refactor: activeEffect for effect cleanup
LittleSound Dec 15, 2023
0331cf0
Merge branch 'main' into feat/vOn-compound-expression
LittleSound Jan 7, 2024
86a8709
feat: use renderEffect and onEffectCleanup drivers
LittleSound Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export function render(_ctx) {
}"
`;

exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", (...args) => (_ctx.a['b' + _ctx.c] && _ctx.a['b' + _ctx.c](...args)))
return n0
}"
`;

exports[`v-on > dynamic arg 1`] = `
"import { template as _template, children as _children, renderEffect as _renderEffect, on as _on } from 'vue/vapor';

Expand All @@ -26,6 +38,34 @@ export function render(_ctx) {
}"
`;

exports[`v-on > dynamic arg with complex exp prefixing 1`] = `
"import { template as _template, children as _children, renderEffect as _renderEffect, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_renderEffect(() => {
_on(n1, _ctx.event(_ctx.foo), (...args) => (_ctx.handler && _ctx.handler(...args)))
})
return n0
}"
`;

exports[`v-on > dynamic arg with prefixing 1`] = `
"import { template as _template, children as _children, renderEffect as _renderEffect, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_renderEffect(() => {
_on(n1, _ctx.event, (...args) => (_ctx.handler && _ctx.handler(...args)))
})
return n0
}"
`;

exports[`v-on > event modifier 1`] = `
"import { template as _template, children as _children, on as _on, withModifiers as _withModifiers, withKeys as _withKeys } from 'vue/vapor';

Expand Down Expand Up @@ -59,6 +99,133 @@ export function render(_ctx) {
}"
`;

exports[`v-on > function expression w/ prefixIdentifiers: true 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", e => _ctx.foo(e))
return n0
}"
`;

exports[`v-on > inline statement w/ prefixIdentifiers: true 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $event => (_ctx.foo($event)))
return n0
}"
`;

exports[`v-on > multiple inline statements w/ prefixIdentifiers: true 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $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 { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $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 { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", (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 { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click",
$event => {
_ctx.foo($event)
}
)
return n0
}"
`;

exports[`v-on > should NOT wrap as function if expression is already function expression 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $event => _ctx.foo($event))
return n0
}"
`;

exports[`v-on > should NOT wrap as function if expression is complex member expression 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", (...args) => (_ctx.a['b' + _ctx.c] && _ctx.a['b' + _ctx.c](...args)))
return n0
}"
`;

exports[`v-on > should handle multi-line statement 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $event => {
_ctx.foo();
_ctx.bar()
})
return n0
}"
`;

exports[`v-on > should handle multiple inline statement 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $event => {_ctx.foo();_ctx.bar()})
return n0
}"
`;

exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
"import { template as _template, children as _children, on as _on, withModifiers as _withModifiers } from 'vue/vapor';

Expand Down Expand Up @@ -148,6 +315,32 @@ export function render(_ctx) {
}"
`;

exports[`v-on > should wrap as function if expression is inline statement 1`] = `
"import { template as _template, children as _children, on as _on } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_on(n1, "click", $event => (_ctx.i++))
return n0
}"
`;

exports[`v-on > should wrap both for dynamic key event w/ left/right modifiers 1`] = `
"import { template as _template, children as _children, renderEffect as _renderEffect, on as _on, withKeys as _withKeys, withModifiers as _withModifiers } from 'vue/vapor';

export function render(_ctx) {
const t0 = _template("<div></div>")
const n0 = t0()
const { 0: [n1],} = _children(n0)
_renderEffect(() => {
_on(n1, _ctx.e, _withKeys(_withModifiers((...args) => (_ctx.test && _ctx.test(...args)), ["left"]), ["left"]))
})
return n0
}"
`;

exports[`v-on > should wrap keys guard for keyboard events or dynamic events 1`] = `
"import { template as _template, children as _children, on as _on, withKeys as _withKeys, withModifiers as _withModifiers } from 'vue/vapor';

Expand Down
Loading