refactor(compiler-vapor): don't reference root element

This commit is contained in:
三咲智子 Kevin Deng 2024-02-23 14:03:21 +08:00
parent 7aae631d8c
commit e91dde5d22
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
20 changed files with 476 additions and 483 deletions

View File

@ -5,9 +5,9 @@ exports[`compile > bindings 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setText(n1, "count is ", _ctx.count, "."))
return n1
const n0 = t0()
_renderEffect(() => _setText(n0, "count is ", _ctx.count, "."))
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`compile > custom directive > basic 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_resolveDirective("vTest")], [_resolveDirective("vHello"), void 0, void 0, { world: true }]])
return n1
const n0 = t0()
_withDirectives(n0, [[_resolveDirective("vTest")], [_resolveDirective("vHello"), void 0, void 0, { world: true }]])
return n0
}"
`;
@ -27,9 +27,9 @@ exports[`compile > directives > custom directive > basic 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample]])
return n0
}"
`;
@ -38,9 +38,9 @@ exports[`compile > directives > custom directive > binding value 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg]])
return n0
}"
`;
@ -49,9 +49,9 @@ exports[`compile > directives > custom directive > dynamic parameters 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, _ctx.foo]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, _ctx.foo]])
return n0
}"
`;
@ -60,9 +60,9 @@ exports[`compile > directives > custom directive > modifiers 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, void 0, { bar: true }]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, void 0, { bar: true }]])
return n0
}"
`;
@ -71,9 +71,9 @@ exports[`compile > directives > custom directive > modifiers w/o binding 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, void 0, void 0, { "foo-bar": true }]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, void 0, void 0, { "foo-bar": true }]])
return n0
}"
`;
@ -82,9 +82,9 @@ exports[`compile > directives > custom directive > static parameters 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo"]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, "foo"]])
return n0
}"
`;
@ -93,9 +93,9 @@ exports[`compile > directives > custom directive > static parameters and modifie
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo", { bar: true }]])
return n1
const n0 = t0()
_withDirectives(n0, [[_ctx.vExample, () => _ctx.msg, "foo", { bar: true }]])
return n0
}"
`;
@ -104,8 +104,8 @@ exports[`compile > directives > v-cloak > basic 1`] = `
const t0 = _template("<div>test</div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;
@ -114,8 +114,8 @@ exports[`compile > directives > v-pre > basic 1`] = `
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;
@ -125,13 +125,13 @@ const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
const t1 = _template("<div><Comp></Comp></div>")
export function render(_ctx) {
const n1 = t0()
const n3 = t1()
const n2 = _createTextNode()
_append(n3, n2)
_renderEffect(() => _setText(n2, _ctx.bar))
_renderEffect(() => _setDynamicProp(n3, "id", _ctx.foo))
return [n1, n3]
const n0 = t0()
const n2 = t1()
const n1 = _createTextNode()
_append(n2, n1)
_renderEffect(() => _setText(n1, _ctx.bar))
_renderEffect(() => _setDynamicProp(n2, "id", _ctx.foo))
return [n0, n2]
}"
`;
@ -139,9 +139,9 @@ exports[`compile > dynamic root 1`] = `
"import { createTextNode as _createTextNode, setText as _setText } from 'vue/vapor';
export function render(_ctx) {
const n1 = _createTextNode()
_setText(n1, 1, 2)
return n1
const n0 = _createTextNode()
_setText(n0, 1, 2)
return n0
}"
`;
@ -150,27 +150,27 @@ exports[`compile > dynamic root nodes and interpolation 1`] = `
const t0 = _template("<button></button>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.handleClick)
_renderEffect(() => _setText(n1, _ctx.count, "foo", _ctx.count, "foo", _ctx.count))
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.count))
return n1
const n0 = t0()
_on(n0, "click", () => _ctx.handleClick)
_renderEffect(() => _setText(n0, _ctx.count, "foo", _ctx.count, "foo", _ctx.count))
_renderEffect(() => _setDynamicProp(n0, "id", _ctx.count))
return n0
}"
`;
exports[`compile > expression parsing > interpolation 1`] = `
"(() => {
const n1 = _createTextNode()
_renderEffect(() => _setText(n1, a + b.value))
return n1
const n0 = _createTextNode()
_renderEffect(() => _setText(n0, a + b.value))
return n0
})()"
`;
exports[`compile > expression parsing > v-bind 1`] = `
"(() => {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { [key.value+1]: _unref(foo)[key.value+1]() }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { [key.value+1]: _unref(foo)[key.value+1]() }))
return n0
})()"
`;
@ -181,10 +181,10 @@ const t1 = _template("<span></span>")
const t2 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
const n2 = t1()
const n3 = t2()
return [n1, n2, n3]
const n0 = t0()
const n1 = t1()
const n2 = t2()
return [n0, n1, n2]
}"
`;
@ -192,9 +192,9 @@ exports[`compile > static + dynamic root 1`] = `
"import { createTextNode as _createTextNode, setText as _setText } from 'vue/vapor';
export function render(_ctx) {
const n1 = _createTextNode()
_setText(n1, 1, 2, "3", 4, 5, "6", 7, 8, "9", 'A', 'B')
return n1
const n0 = _createTextNode()
_setText(n0, 1, 2, "3", 4, 5, "6", 7, 8, "9", 'A', 'B')
return n0
}"
`;
@ -203,7 +203,7 @@ exports[`compile > static template 1`] = `
const t0 = _template("<div><p>hello</p><input><span></span></div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`compiler: element transform > props merging: class 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setClass(n1, ["foo", { bar: _ctx.isBar }]))
return n1
const n0 = t0()
_renderEffect(() => _setClass(n0, ["foo", { bar: _ctx.isBar }]))
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`compiler: element transform > props merging: style 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setStyle(n1, ["color: green", { color: 'red' }]))
return n1
const n0 = t0()
_renderEffect(() => _setStyle(n0, ["color: green", { color: 'red' }]))
return n0
}"
`;
@ -27,8 +27,8 @@ exports[`compiler: element transform > static props 1`] = `
const t0 = _template("<div id=\\"foo\\" class=\\"bar\\"></div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;
@ -37,9 +37,9 @@ exports[`compiler: element transform > v-bind="obj" 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, _ctx.obj))
return n0
}"
`;
@ -48,9 +48,9 @@ exports[`compiler: element transform > v-bind="obj" after static prop 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { id: "foo" }, _ctx.obj))
return n0
}"
`;
@ -59,9 +59,9 @@ exports[`compiler: element transform > v-bind="obj" before static prop 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, _ctx.obj, { id: "foo" }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, _ctx.obj, { id: "foo" }))
return n0
}"
`;
@ -70,8 +70,8 @@ exports[`compiler: element transform > v-bind="obj" between static props 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj, { class: "bar" }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { id: "foo" }, _ctx.obj, { class: "bar" }))
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`compiler v-bind > .attr modifier 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setAttr(n0, "foo-bar", _ctx.id))
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`compiler v-bind > .attr modifier w/ no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.fooBar))
return n1
const n0 = t0()
_renderEffect(() => _setAttr(n0, "foo-bar", _ctx.fooBar))
return n0
}"
`;
@ -27,9 +27,9 @@ exports[`compiler v-bind > .camel modifier 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProp(n0, "fooBar", _ctx.id))
return n0
}"
`;
@ -39,9 +39,9 @@ import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, tem
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { [_camelize(_ctx.foo)]: _ctx.id }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { [_camelize(_ctx.foo)]: _ctx.id }))
return n0
}"
`;
@ -50,9 +50,9 @@ exports[`compiler v-bind > .camel modifier w/ no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.fooBar))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProp(n0, "fooBar", _ctx.fooBar))
return n0
}"
`;
@ -61,9 +61,9 @@ exports[`compiler v-bind > .prop modifier (shortband) w/ no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
return n1
const n0 = t0()
_renderEffect(() => _setDOMProp(n0, "fooBar", _ctx.fooBar))
return n0
}"
`;
@ -72,9 +72,9 @@ exports[`compiler v-bind > .prop modifier (shorthand) 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setDOMProp(n0, "fooBar", _ctx.id))
return n0
}"
`;
@ -83,9 +83,9 @@ exports[`compiler v-bind > .prop modifier 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setDOMProp(n0, "fooBar", _ctx.id))
return n0
}"
`;
@ -94,9 +94,9 @@ exports[`compiler v-bind > .prop modifier w/ dynamic arg 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { ["." + _ctx.fooBar]: _ctx.id }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { ["." + _ctx.fooBar]: _ctx.id }))
return n0
}"
`;
@ -105,9 +105,9 @@ exports[`compiler v-bind > .prop modifier w/ no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
return n1
const n0 = t0()
_renderEffect(() => _setDOMProp(n0, "fooBar", _ctx.fooBar))
return n0
}"
`;
@ -116,9 +116,9 @@ exports[`compiler v-bind > basic 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProp(n0, "id", _ctx.id))
return n0
}"
`;
@ -127,9 +127,9 @@ exports[`compiler v-bind > dynamic arg 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title }))
return n0
}"
`;
@ -138,9 +138,9 @@ exports[`compiler v-bind > dynamic arg w/ static attribute 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" }))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProps(n0, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" }))
return n0
}"
`;
@ -149,9 +149,9 @@ exports[`compiler v-bind > no expression (shorthand) 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProp(n1, "camel-case", _ctx.camelCase))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProp(n0, "camel-case", _ctx.camelCase))
return n0
}"
`;
@ -160,9 +160,9 @@ exports[`compiler v-bind > no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
return n1
const n0 = t0()
_renderEffect(() => _setDynamicProp(n0, "id", _ctx.id))
return n0
}"
`;
@ -171,7 +171,7 @@ exports[`compiler v-bind > should error if empty expression 1`] = `
const t0 = _template("<div arg></div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;

View File

@ -5,17 +5,17 @@ exports[`compiler: v-for > basic v-for 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = _createFor(() => (_ctx.items), (_block) => {
const n3 = t0()
_on(n3, "click", () => $event => (_ctx.remove(_block.s[0])))
const n0 = _createFor(() => (_ctx.items), (_block) => {
const n2 = t0()
_on(n2, "click", () => $event => (_ctx.remove(_block.s[0])))
const _updateEffect = () => {
const [item] = _block.s
_setText(n3, item)
_setText(n2, item)
}
_renderEffect(_updateEffect)
return [n3, _updateEffect]
return [n2, _updateEffect]
}, (item) => (item.id))
return n1
return n0
}"
`;
@ -24,17 +24,17 @@ exports[`compiler: v-for > multi effect 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = _createFor(() => (_ctx.items), (_block) => {
const n3 = t0()
const n0 = _createFor(() => (_ctx.items), (_block) => {
const n2 = t0()
const _updateEffect = () => {
const [item, index] = _block.s
_setDynamicProp(n3, "item", item)
_setDynamicProp(n3, "index", index)
_setDynamicProp(n2, "item", item)
_setDynamicProp(n2, "index", index)
}
_renderEffect(_updateEffect)
return [n3, _updateEffect]
return [n2, _updateEffect]
})
return n1
return n0
}"
`;
@ -43,10 +43,10 @@ exports[`compiler: v-for > w/o value 1`] = `
const t0 = _template("<div>item</div>")
export function render(_ctx) {
const n1 = _createFor(() => (_ctx.items), (_block) => {
const n3 = t0()
return [n3, () => {}]
const n0 = _createFor(() => (_ctx.items), (_block) => {
const n2 = t0()
return [n2, () => {}]
})
return n1
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`v-html > should convert v-html to innerHTML 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setHtml(n1, _ctx.code))
return n1
const n0 = t0()
_renderEffect(() => _setHtml(n0, _ctx.code))
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`v-html > should raise error and ignore children when v-html is present
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setHtml(n1, _ctx.test))
return n1
const n0 = t0()
_renderEffect(() => _setHtml(n0, _ctx.test))
return n0
}"
`;
@ -27,8 +27,8 @@ exports[`v-html > should raise error if has no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_setHtml(n1, "")
return n1
const n0 = t0()
_setHtml(n0, "")
return n0
}"
`;

View File

@ -5,12 +5,12 @@ exports[`compiler: v-if > basic v-if 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
_renderEffect(() => _setText(n3, _ctx.msg))
return n3
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
_renderEffect(() => _setText(n2, _ctx.msg))
return n2
})
return n1
return n0
}"
`;
@ -24,21 +24,21 @@ const t4 = _template("fine")
const t5 = _template("<input>")
export function render(_ctx) {
const n14 = t5()
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
return n3
const n13 = t5()
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
return n2
}, () => _createIf(() => (_ctx.orNot), () => {
const n6 = t1()
const n7 = t2()
return [n6, n7]
const n5 = t1()
const n6 = t2()
return [n5, n6]
}, () => {
const n11 = t3()
const n12 = t4()
return [n11, n12]
const n10 = t3()
const n11 = t4()
return [n10, n11]
}))
_renderEffect(() => _setText(n14, _ctx.text))
return [n1, n14]
_renderEffect(() => _setText(n13, _ctx.text))
return [n0, n13]
}"
`;
@ -47,15 +47,15 @@ exports[`compiler: v-if > dedupe same template 1`] = `
const t0 = _template("<div>hello</div>")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
return n3
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
return n2
})
const n4 = _createIf(() => (_ctx.ok), () => {
const n6 = t0()
return n6
const n3 = _createIf(() => (_ctx.ok), () => {
const n5 = t0()
return n5
})
return [n1, n4]
return [n0, n3]
}"
`;
@ -66,14 +66,14 @@ const t1 = _template("hello")
const t2 = _template("<p></p>")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
const n4 = t1()
const n5 = t2()
_renderEffect(() => _setText(n5, _ctx.msg))
return [n3, n4, n5]
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
const n3 = t1()
const n4 = t2()
_renderEffect(() => _setText(n4, _ctx.msg))
return [n2, n3, n4]
})
return n1
return n0
}"
`;
@ -83,14 +83,14 @@ const t0 = _template("<div></div>")
const t1 = _template("<p></p>")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
return n3
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
return n2
}, () => {
const n5 = t1()
return n5
const n4 = t1()
return n4
})
return n1
return n0
}"
`;
@ -101,17 +101,17 @@ const t1 = _template("<p></p>")
const t2 = _template("fine")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
return n3
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
return n2
}, () => _createIf(() => (_ctx.orNot), () => {
const n5 = t1()
return n5
const n4 = t1()
return n4
}, () => {
const n8 = t2()
return n8
const n7 = t2()
return n7
}))
return n1
return n0
}"
`;
@ -121,13 +121,13 @@ const t0 = _template("<div></div>")
const t1 = _template("<p></p>")
export function render(_ctx) {
const n1 = _createIf(() => (_ctx.ok), () => {
const n3 = t0()
return n3
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
return n2
}, () => _createIf(() => (_ctx.orNot), () => {
const n5 = t1()
return n5
const n4 = t1()
return n4
}))
return n1
return n0
}"
`;

View File

@ -5,10 +5,10 @@ exports[`compiler: vModel transform > modifiers > .lazy 1`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { lazy: true }]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { lazy: true }]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -17,10 +17,10 @@ exports[`compiler: vModel transform > modifiers > .number 1`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { number: true }]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { number: true }]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -29,10 +29,10 @@ exports[`compiler: vModel transform > modifiers > .trim 1`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { trim: true }]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model, void 0, { trim: true }]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -41,10 +41,10 @@ exports[`compiler: vModel transform > should support input (checkbox) 1`] = `
const t0 = _template("<input type=\\"checkbox\\">")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelCheckbox, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelCheckbox, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -53,10 +53,10 @@ exports[`compiler: vModel transform > should support input (dynamic type) 1`] =
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -65,10 +65,10 @@ exports[`compiler: vModel transform > should support input (radio) 1`] = `
const t0 = _template("<input type=\\"radio\\">")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelRadio, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelRadio, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -77,10 +77,10 @@ exports[`compiler: vModel transform > should support input (text) 1`] = `
const t0 = _template("<input type=\\"text\\">")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -89,10 +89,10 @@ exports[`compiler: vModel transform > should support select 1`] = `
const t0 = _template("<select></select>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelSelect, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelSelect, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -101,10 +101,10 @@ exports[`compiler: vModel transform > should support simple expression 1`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -113,10 +113,10 @@ exports[`compiler: vModel transform > should support textarea 1`] = `
const t0 = _template("<textarea></textarea>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelText, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;
@ -125,11 +125,11 @@ exports[`compiler: vModel transform > should support w/ dynamic v-bind 1`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
_renderEffect(() => _setDynamicProps(n0, _ctx.obj))
return n0
}"
`;
@ -138,9 +138,9 @@ exports[`compiler: vModel transform > should support w/ dynamic v-bind 2`] = `
const t0 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
_on(n1, "update:modelValue", () => $event => (_ctx.model = $event))
return n1
const n0 = t0()
_withDirectives(n0, [[_vModelDynamic, () => _ctx.model]])
_on(n0, "update:modelValue", () => $event => (_ctx.model = $event))
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
return n1
const n0 = t0()
_on(n0, "click", () => _ctx.a['b' + _ctx.c])
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`v-on > dynamic arg 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
return n1
const n0 = t0()
_renderEffect(() => _on(n0, _ctx.event, () => _ctx.handler))
return n0
}"
`;
@ -27,9 +27,9 @@ exports[`v-on > dynamic arg with complex exp prefixing 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _on(n1, _ctx.event(_ctx.foo), () => _ctx.handler))
return n1
const n0 = t0()
_renderEffect(() => _on(n0, _ctx.event(_ctx.foo), () => _ctx.handler))
return n0
}"
`;
@ -38,9 +38,9 @@ exports[`v-on > dynamic arg with prefixing 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
return n1
const n0 = t0()
_renderEffect(() => _on(n0, _ctx.event, () => _ctx.handler))
return n0
}"
`;
@ -52,13 +52,14 @@ const t2 = _template("<div></div>")
const t3 = _template("<input>")
export function render(_ctx) {
const n1 = t0()
const n2 = t1()
const n3 = t0()
const n0 = t0()
const n1 = t1()
const n2 = t0()
const n3 = t2()
const n4 = t2()
const n5 = t2()
const n6 = t0()
const n7 = t2()
const n5 = t0()
const n6 = t2()
const n7 = t3()
const n8 = t3()
const n9 = t3()
const n10 = t3()
@ -73,69 +74,68 @@ export function render(_ctx) {
const n19 = t3()
const n20 = t3()
const n21 = t3()
const n22 = t3()
_on(n1, "click", () => _ctx.handleEvent, undefined, {
_on(n0, "click", () => _ctx.handleEvent, undefined, {
modifiers: ["stop"]
})
_on(n2, "submit", () => _ctx.handleEvent, undefined, {
_on(n1, "submit", () => _ctx.handleEvent, undefined, {
modifiers: ["prevent"]
})
_on(n3, "click", () => _ctx.handleEvent, undefined, {
_on(n2, "click", () => _ctx.handleEvent, undefined, {
modifiers: ["stop", "prevent"]
})
_on(n4, "click", () => _ctx.handleEvent, undefined, {
_on(n3, "click", () => _ctx.handleEvent, undefined, {
modifiers: ["self"]
})
_on(n5, "click", () => _ctx.handleEvent, { capture: true })
_on(n6, "click", () => _ctx.handleEvent, { once: true })
_on(n7, "scroll", () => _ctx.handleEvent, { passive: true })
_on(n8, "contextmenu", () => _ctx.handleEvent, undefined, {
_on(n4, "click", () => _ctx.handleEvent, { capture: true })
_on(n5, "click", () => _ctx.handleEvent, { once: true })
_on(n6, "scroll", () => _ctx.handleEvent, { passive: true })
_on(n7, "contextmenu", () => _ctx.handleEvent, undefined, {
modifiers: ["right"]
})
_on(n9, "click", () => _ctx.handleEvent, undefined, {
_on(n8, "click", () => _ctx.handleEvent, undefined, {
modifiers: ["left"]
})
_on(n10, "mouseup", () => _ctx.handleEvent, undefined, {
_on(n9, "mouseup", () => _ctx.handleEvent, undefined, {
modifiers: ["middle"]
})
_on(n11, "contextmenu", () => _ctx.handleEvent, undefined, {
_on(n10, "contextmenu", () => _ctx.handleEvent, undefined, {
modifiers: ["right"]
})
_on(n12, "keyup", () => _ctx.handleEvent, undefined, {
_on(n11, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["enter"]
})
_on(n13, "keyup", () => _ctx.handleEvent, undefined, {
_on(n12, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["tab"]
})
_on(n14, "keyup", () => _ctx.handleEvent, undefined, {
_on(n13, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["delete"]
})
_on(n15, "keyup", () => _ctx.handleEvent, undefined, {
_on(n14, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["esc"]
})
_on(n16, "keyup", () => _ctx.handleEvent, undefined, {
_on(n15, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["space"]
})
_on(n17, "keyup", () => _ctx.handleEvent, undefined, {
_on(n16, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["up"]
})
_on(n18, "keyup", () => _ctx.handleEvent, undefined, {
_on(n17, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["down"]
})
_on(n19, "keyup", () => _ctx.handleEvent, undefined, {
_on(n18, "keyup", () => _ctx.handleEvent, undefined, {
keys: ["left"]
})
_on(n20, "keyup", () => _ctx.submit, undefined, {
_on(n19, "keyup", () => _ctx.submit, undefined, {
modifiers: ["middle"]
})
_on(n21, "keyup", () => _ctx.submit, undefined, {
_on(n20, "keyup", () => _ctx.submit, undefined, {
modifiers: ["middle", "self"]
})
_on(n22, "keyup", () => _ctx.handleEvent, undefined, {
_on(n21, "keyup", () => _ctx.handleEvent, undefined, {
modifiers: ["self"],
keys: ["enter"]
})
return [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22]
return [n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21]
}"
`;
@ -144,9 +144,9 @@ exports[`v-on > function expression w/ prefixIdentifiers: true 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => e => _ctx.foo(e))
return n1
const n0 = t0()
_on(n0, "click", () => e => _ctx.foo(e))
return n0
}"
`;
@ -155,9 +155,9 @@ exports[`v-on > inline statement w/ prefixIdentifiers: true 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => (_ctx.foo($event)))
return n1
const n0 = t0()
_on(n0, "click", () => $event => (_ctx.foo($event)))
return n0
}"
`;
@ -166,9 +166,9 @@ exports[`v-on > multiple inline statements w/ prefixIdentifiers: true 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => {_ctx.foo($event);_ctx.bar()})
return n1
const n0 = t0()
_on(n0, "click", () => $event => {_ctx.foo($event);_ctx.bar()})
return n0
}"
`;
@ -177,9 +177,9 @@ exports[`v-on > should NOT add a prefix to $event if the expression is a functio
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => {_ctx.i++;_ctx.foo($event)})
return n1
const n0 = t0()
_on(n0, "click", () => $event => {_ctx.i++;_ctx.foo($event)})
return n0
}"
`;
@ -188,9 +188,9 @@ exports[`v-on > should NOT wrap as function if expression is already function ex
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => (e: any): any => _ctx.foo(e))
return n1
const n0 = t0()
_on(n0, "click", () => (e: any): any => _ctx.foo(e))
return n0
}"
`;
@ -199,13 +199,13 @@ exports[`v-on > should NOT wrap as function if expression is already function ex
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () =>
const n0 = t0()
_on(n0, "click", () =>
$event => {
_ctx.foo($event)
}
)
return n1
return n0
}"
`;
@ -214,9 +214,9 @@ exports[`v-on > should NOT wrap as function if expression is already function ex
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => _ctx.foo($event))
return n1
const n0 = t0()
_on(n0, "click", () => $event => _ctx.foo($event))
return n0
}"
`;
@ -225,9 +225,9 @@ exports[`v-on > should NOT wrap as function if expression is complex member expr
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
return n1
const n0 = t0()
_on(n0, "click", () => _ctx.a['b' + _ctx.c])
return n0
}"
`;
@ -236,12 +236,12 @@ exports[`v-on > should handle multi-line statement 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => {
const n0 = t0()
_on(n0, "click", () => $event => {
_ctx.foo();
_ctx.bar()
})
return n1
return n0
}"
`;
@ -250,9 +250,9 @@ exports[`v-on > should handle multiple inline statement 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => {_ctx.foo();_ctx.bar()})
return n1
const n0 = t0()
_on(n0, "click", () => $event => {_ctx.foo();_ctx.bar()})
return n0
}"
`;
@ -261,9 +261,9 @@ exports[`v-on > should not prefix member expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.foo.bar)
return n1
const n0 = t0()
_on(n0, "click", () => _ctx.foo.bar)
return n0
}"
`;
@ -272,11 +272,11 @@ exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "keyup", () => _ctx.test, undefined, {
const n0 = t0()
_on(n0, "keyup", () => _ctx.test, undefined, {
modifiers: ["exact"]
})
return n1
return n0
}"
`;
@ -285,14 +285,14 @@ exports[`v-on > should support multiple events and modifiers options w/ prefixId
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.test, undefined, {
const n0 = t0()
_on(n0, "click", () => _ctx.test, undefined, {
modifiers: ["stop"]
})
_on(n1, "keyup", () => _ctx.test, undefined, {
_on(n0, "keyup", () => _ctx.test, undefined, {
keys: ["enter"]
})
return n1
return n0
}"
`;
@ -301,11 +301,11 @@ exports[`v-on > should support multiple modifiers and event options w/ prefixIde
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.test, { capture: true, once: true }, {
const n0 = t0()
_on(n0, "click", () => _ctx.test, { capture: true, once: true }, {
modifiers: ["stop", "prevent"]
})
return n1
return n0
}"
`;
@ -314,11 +314,11 @@ exports[`v-on > should transform click.middle 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "mouseup", () => _ctx.test, undefined, {
const n0 = t0()
_on(n0, "mouseup", () => _ctx.test, undefined, {
modifiers: ["middle"]
})
return n1
return n0
}"
`;
@ -327,13 +327,13 @@ exports[`v-on > should transform click.middle 2`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
const n0 = t0()
_renderEffect(() => {
_on(n1, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, {
_on(n0, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, {
modifiers: ["middle"]
})
})
return n1
return n0
}"
`;
@ -342,11 +342,11 @@ exports[`v-on > should transform click.right 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "contextmenu", () => _ctx.test, undefined, {
const n0 = t0()
_on(n0, "contextmenu", () => _ctx.test, undefined, {
modifiers: ["right"]
})
return n1
return n0
}"
`;
@ -355,14 +355,14 @@ exports[`v-on > should transform click.right 2`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
const n0 = t0()
_renderEffect(() => {
_on(n1, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, {
_on(n0, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, {
modifiers: ["right"],
keys: ["right"]
})
})
return n1
return n0
}"
`;
@ -371,9 +371,9 @@ exports[`v-on > should wrap as function if expression is inline statement 1`] =
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => $event => (_ctx.i++))
return n1
const n0 = t0()
_on(n0, "click", () => $event => (_ctx.i++))
return n0
}"
`;
@ -382,26 +382,26 @@ exports[`v-on > should wrap both for dynamic key event w/ left/right modifiers 1
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
const n0 = t0()
_renderEffect(() => {
_on(n1, _ctx.e, () => _ctx.test, undefined, {
_on(n0, _ctx.e, () => _ctx.test, undefined, {
modifiers: ["left"],
keys: ["left"]
})
})
return n1
return n0
}"
`;
exports[`v-on > should wrap in unref if identifier is setup-maybe-ref w/ inline: true 1`] = `
"(() => {
const n0 = t0()
const n1 = t0()
const n2 = t0()
const n3 = t0()
_on(n1, "click", () => $event => (x.value=_unref(y)))
_on(n2, "click", () => $event => (x.value++))
_on(n3, "click", () => $event => ({ x: x.value } = _unref(y)))
return [n1, n2, n3]
_on(n0, "click", () => $event => (x.value=_unref(y)))
_on(n1, "click", () => $event => (x.value++))
_on(n2, "click", () => $event => ({ x: x.value } = _unref(y)))
return [n0, n1, n2]
})()"
`;
@ -410,12 +410,12 @@ exports[`v-on > should wrap keys guard for keyboard events or dynamic events 1`]
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "keydown", () => _ctx.test, { capture: true }, {
const n0 = t0()
_on(n0, "keydown", () => _ctx.test, { capture: true }, {
modifiers: ["stop", "ctrl"],
keys: ["a"]
})
return n1
return n0
}"
`;
@ -424,11 +424,11 @@ exports[`v-on > should wrap keys guard for static key event w/ left/right modifi
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "keyup", () => _ctx.test, undefined, {
const n0 = t0()
_on(n0, "keyup", () => _ctx.test, undefined, {
keys: ["left"]
})
return n1
return n0
}"
`;
@ -437,8 +437,8 @@ exports[`v-on > simple expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_on(n1, "click", () => _ctx.handleClick)
return n1
const n0 = t0()
_on(n0, "click", () => _ctx.handleClick)
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`compiler: v-once > as root node 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_setDynamicProp(n1, "id", _ctx.foo)
return n1
const n0 = t0()
_setDynamicProp(n0, "id", _ctx.foo)
return n0
}"
`;
@ -16,13 +16,13 @@ exports[`compiler: v-once > basic 1`] = `
const t0 = _template("<div><span></span></div>")
export function render(_ctx) {
const n3 = t0()
const n2 = _children(n3, 0)
const n1 = _createTextNode()
_setText(n1, _ctx.msg, " ")
_setClass(n2, _ctx.clz)
_prepend(n3, n1)
return n3
const n2 = t0()
const n1 = _children(n2, 0)
const n0 = _createTextNode()
_setText(n0, _ctx.msg, " ")
_setClass(n1, _ctx.clz)
_prepend(n2, n0)
return n2
}"
`;
@ -31,8 +31,8 @@ exports[`compiler: v-once > inside v-once 1`] = `
const t0 = _template("<div><div></div></div>")
export function render(_ctx) {
const n1 = t0()
return n1
const n0 = t0()
return n0
}"
`;
@ -41,9 +41,9 @@ exports[`compiler: v-once > on nested plain element 1`] = `
const t0 = _template("<div><div></div></div>")
export function render(_ctx) {
const n2 = t0()
const n1 = _children(n2, 0)
_setDynamicProp(n1, "id", _ctx.foo)
return n2
const n1 = t0()
const n0 = _children(n1, 0)
_setDynamicProp(n0, "id", _ctx.foo)
return n1
}"
`;

View File

@ -5,8 +5,8 @@ exports[`compiler: v-show transform > simple expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_withDirectives(n1, [[_vShow, () => _ctx.foo]])
return n1
const n0 = t0()
_withDirectives(n0, [[_vShow, () => _ctx.foo]])
return n0
}"
`;

View File

@ -5,9 +5,9 @@ exports[`v-text > should convert v-text to textContent 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setText(n1, _ctx.str))
return n1
const n0 = t0()
_renderEffect(() => _setText(n0, _ctx.str))
return n0
}"
`;
@ -16,9 +16,9 @@ exports[`v-text > should raise error and ignore children when v-text is present
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_renderEffect(() => _setText(n1, _ctx.test))
return n1
const n0 = t0()
_renderEffect(() => _setText(n0, _ctx.test))
return n0
}"
`;
@ -27,8 +27,8 @@ exports[`v-text > should raise error if has no expression 1`] = `
const t0 = _template("<div></div>")
export function render(_ctx) {
const n1 = t0()
_setText(n1, "")
return n1
const n0 = t0()
_setText(n0, "")
return n0
}"
`;

View File

@ -43,7 +43,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
{
type: 4,
@ -55,7 +55,7 @@ describe('compiler: element transform', () => {
],
},
])
expect(code).contains('_setDynamicProps(n1, _ctx.obj)')
expect(code).contains('_setDynamicProps(n0, _ctx.obj)')
})
test('v-bind="obj" after static prop', () => {
@ -75,7 +75,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
[
{
@ -103,7 +103,7 @@ describe('compiler: element transform', () => {
],
},
])
expect(code).contains('_setDynamicProps(n1, { id: "foo" }, _ctx.obj)')
expect(code).contains('_setDynamicProps(n0, { id: "foo" }, _ctx.obj)')
})
test('v-bind="obj" before static prop', () => {
@ -123,7 +123,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
{
type: NodeTypes.SIMPLE_EXPRESSION,
@ -151,7 +151,7 @@ describe('compiler: element transform', () => {
],
},
])
expect(code).contains('_setDynamicProps(n1, _ctx.obj, { id: "foo" })')
expect(code).contains('_setDynamicProps(n0, _ctx.obj, { id: "foo" })')
})
test('v-bind="obj" between static props', () => {
@ -171,7 +171,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
[
{
@ -216,7 +216,7 @@ describe('compiler: element transform', () => {
},
])
expect(code).contains(
'_setDynamicProps(n1, { id: "foo" }, _ctx.obj, { class: "bar" })',
'_setDynamicProps(n0, { id: "foo" }, _ctx.obj, { class: "bar" })',
)
})
@ -229,7 +229,7 @@ describe('compiler: element transform', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'click',
@ -274,7 +274,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_PROP,
element: 1,
element: 0,
prop: {
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
@ -319,7 +319,7 @@ describe('compiler: element transform', () => {
operations: [
{
type: IRNodeTypes.SET_PROP,
element: 1,
element: 0,
prop: {
key: {
type: NodeTypes.SIMPLE_EXPRESSION,

View File

@ -20,7 +20,7 @@ describe('compiler v-bind', () => {
const { ir, code } = compileWithVBind(`<div v-bind:id="id"/>`)
expect(ir.block.dynamic.children[0]).toMatchObject({
id: 1,
id: 0,
flags: DynamicFlag.REFERENCED,
})
expect(ir.template).toEqual(['<div></div>'])
@ -38,7 +38,7 @@ describe('compiler v-bind', () => {
operations: [
{
type: IRNodeTypes.SET_PROP,
element: 1,
element: 0,
prop: {
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
@ -74,7 +74,7 @@ describe('compiler v-bind', () => {
})
expect(code).matchSnapshot()
expect(code).contains('_setDynamicProp(n1, "id", _ctx.id)')
expect(code).contains('_setDynamicProp(n0, "id", _ctx.id)')
})
test('no expression', () => {
@ -104,7 +104,7 @@ describe('compiler v-bind', () => {
],
},
})
expect(code).contains('_setDynamicProp(n1, "id", _ctx.id)')
expect(code).contains('_setDynamicProp(n0, "id", _ctx.id)')
})
test('no expression (shorthand)', () => {
@ -126,7 +126,7 @@ describe('compiler v-bind', () => {
],
},
})
expect(code).contains('_setDynamicProp(n1, "camel-case", _ctx.camelCase)')
expect(code).contains('_setDynamicProp(n0, "camel-case", _ctx.camelCase)')
})
test('dynamic arg', () => {
@ -136,7 +136,7 @@ describe('compiler v-bind', () => {
expect(code).matchSnapshot()
expect(ir.block.effect[0].operations[0]).toMatchObject({
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
[
{
@ -171,7 +171,7 @@ describe('compiler v-bind', () => {
],
})
expect(code).contains(
'_setDynamicProps(n1, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title })',
'_setDynamicProps(n0, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title })',
)
})
@ -182,7 +182,7 @@ describe('compiler v-bind', () => {
expect(code).matchSnapshot()
expect(ir.block.effect[0].operations[0]).toMatchObject({
type: IRNodeTypes.SET_DYNAMIC_PROPS,
element: 1,
element: 0,
props: [
[
{
@ -224,7 +224,7 @@ describe('compiler v-bind', () => {
],
})
expect(code).contains(
'_setDynamicProps(n1, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" })',
'_setDynamicProps(n0, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" })',
)
})
@ -286,7 +286,7 @@ describe('compiler v-bind', () => {
})
expect(code).matchSnapshot()
expect(code).contains('_setDynamicProp(n1, "fooBar", _ctx.id)')
expect(code).contains('_setDynamicProp(n0, "fooBar", _ctx.id)')
})
test('.camel modifier w/ no expression', () => {
@ -310,7 +310,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setDynamicProp(n1, "fooBar", _ctx.fooBar)')
expect(code).contains('_setDynamicProp(n0, "fooBar", _ctx.fooBar)')
})
test('.camel modifier w/ dynamic arg', () => {
@ -341,7 +341,7 @@ describe('compiler v-bind', () => {
expect(code).matchSnapshot()
expect(code).contains('renderEffect')
expect(code).contains(
`_setDynamicProps(n1, { [_camelize(_ctx.foo)]: _ctx.id })`,
`_setDynamicProps(n0, { [_camelize(_ctx.foo)]: _ctx.id })`,
)
})
@ -368,7 +368,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setDOMProp(n1, "fooBar", _ctx.id)')
expect(code).contains('_setDOMProp(n0, "fooBar", _ctx.id)')
})
test('.prop modifier w/ no expression', () => {
@ -392,7 +392,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setDOMProp(n1, "fooBar", _ctx.fooBar)')
expect(code).contains('_setDOMProp(n0, "fooBar", _ctx.fooBar)')
})
test('.prop modifier w/ dynamic arg', () => {
@ -422,7 +422,7 @@ describe('compiler v-bind', () => {
})
expect(code).contains('renderEffect')
expect(code).contains(
`_setDynamicProps(n1, { ["." + _ctx.fooBar]: _ctx.id })`,
`_setDynamicProps(n0, { ["." + _ctx.fooBar]: _ctx.id })`,
)
})
@ -449,7 +449,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setDOMProp(n1, "fooBar", _ctx.id)')
expect(code).contains('_setDOMProp(n0, "fooBar", _ctx.id)')
})
test('.prop modifier (shortband) w/ no expression', () => {
@ -473,7 +473,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setDOMProp(n1, "fooBar", _ctx.fooBar)')
expect(code).contains('_setDOMProp(n0, "fooBar", _ctx.fooBar)')
})
test('.attr modifier', () => {
@ -497,7 +497,7 @@ describe('compiler v-bind', () => {
},
})
expect(code).contains('renderEffect')
expect(code).contains('_setAttr(n1, "foo-bar", _ctx.id)')
expect(code).contains('_setAttr(n0, "foo-bar", _ctx.id)')
})
test('.attr modifier w/ no expression', () => {
@ -522,6 +522,6 @@ describe('compiler v-bind', () => {
})
expect(code).contains('renderEffect')
expect(code).contains('_setAttr(n1, "foo-bar", _ctx.fooBar)')
expect(code).contains('_setAttr(n0, "foo-bar", _ctx.fooBar)')
})
})

View File

@ -37,7 +37,7 @@ describe('compiler: v-for', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.FOR,
id: 1,
id: 0,
source: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'items',
@ -60,10 +60,9 @@ describe('compiler: v-for', () => {
},
},
])
expect(ir.block.returns).toEqual([1])
expect(ir.block.returns).toEqual([0])
expect(ir.block.dynamic).toMatchObject({
id: 0,
children: { 0: { id: 1 } },
children: [{ id: 0 }],
})
expect(ir.block.effect).toEqual([])
expect((ir.block.operation[0] as ForIRNode).render.effect).lengthOf(1)

View File

@ -41,7 +41,7 @@ describe('v-html', () => {
operations: [
{
type: IRNodeTypes.SET_HTML,
element: 1,
element: 0,
value: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'code',
@ -83,7 +83,7 @@ describe('v-html', () => {
operations: [
{
type: IRNodeTypes.SET_HTML,
element: 1,
element: 0,
value: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'test',

View File

@ -39,7 +39,7 @@ describe('compiler: v-if', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.IF,
id: 1,
id: 0,
condition: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'ok',
@ -48,20 +48,15 @@ describe('compiler: v-if', () => {
positive: {
type: IRNodeTypes.BLOCK,
dynamic: {
children: [
{
template: 0,
},
],
children: [{ template: 0 }],
},
},
},
])
expect(ir.block.returns).toEqual([1])
expect(ir.block.returns).toEqual([0])
expect(ir.block.dynamic).toMatchObject({
id: 0,
children: { 0: { id: 1 } },
children: [{ id: 0 }],
})
expect(ir.block.effect).toEqual([])
@ -83,7 +78,7 @@ describe('compiler: v-if', () => {
operations: [
{
type: IRNodeTypes.SET_TEXT,
element: 5,
element: 4,
values: [
{
content: 'msg',
@ -96,10 +91,10 @@ describe('compiler: v-if', () => {
},
])
expect((ir.block.operation[0] as IfIRNode).positive.dynamic).toMatchObject({
id: 2,
id: 1,
children: {
2: {
id: 5,
id: 4,
},
},
})
@ -111,7 +106,7 @@ describe('compiler: v-if', () => {
)
expect(code).matchSnapshot()
expect(ir.template).toEqual(['<div>hello</div>'])
expect(ir.block.returns).toEqual([1, 4])
expect(ir.block.returns).toEqual([0, 3])
})
test.todo('v-if with v-once')
@ -130,7 +125,7 @@ describe('compiler: v-if', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.IF,
id: 1,
id: 0,
condition: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'ok',
@ -150,7 +145,7 @@ describe('compiler: v-if', () => {
},
},
])
expect(ir.block.returns).toEqual([1])
expect(ir.block.returns).toEqual([0])
})
test('v-if + v-else-if', () => {
@ -163,7 +158,7 @@ describe('compiler: v-if', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.IF,
id: 1,
id: 0,
condition: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'ok',
@ -191,7 +186,7 @@ describe('compiler: v-if', () => {
},
},
])
expect(ir.block.returns).toEqual([1])
expect(ir.block.returns).toEqual([0])
})
test('v-if + v-else-if + v-else', () => {
@ -201,11 +196,11 @@ describe('compiler: v-if', () => {
expect(code).matchSnapshot()
expect(ir.template).toEqual(['<div></div>', '<p></p>', 'fine'])
expect(ir.block.returns).toEqual([1])
expect(ir.block.returns).toEqual([0])
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.IF,
id: 1,
id: 0,
positive: {
type: IRNodeTypes.BLOCK,
dynamic: {

View File

@ -32,7 +32,7 @@ describe('v-on', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'click',
@ -96,7 +96,7 @@ describe('v-on', () => {
expect(ir.block.effect[0].operations[0]).toMatchObject({
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'event',
@ -135,7 +135,7 @@ describe('v-on', () => {
expect(ir.block.effect[0].operations[0]).toMatchObject({
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'event(foo)',
@ -162,7 +162,7 @@ describe('v-on', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
value: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'i++',
@ -172,7 +172,7 @@ describe('v-on', () => {
])
expect(code).matchSnapshot()
expect(code).contains('_on(n1, "click", () => $event => (_ctx.i++))')
expect(code).contains('_on(n0, "click", () => $event => (_ctx.i++))')
})
test('should wrap in unref if identifier is setup-maybe-ref w/ inline: true', () => {
@ -192,11 +192,11 @@ describe('v-on', () => {
expect(vaporHelpers).contains('unref')
expect(helpers.size).toBe(0)
expect(code).contains(
'_on(n1, "click", () => $event => (x.value=_unref(y)))',
'_on(n0, "click", () => $event => (x.value=_unref(y)))',
)
expect(code).contains('_on(n2, "click", () => $event => (x.value++))')
expect(code).contains('_on(n1, "click", () => $event => (x.value++))')
expect(code).contains(
'_on(n3, "click", () => $event => ({ x: x.value } = _unref(y)))',
'_on(n2, "click", () => $event => ({ x: x.value } = _unref(y)))',
)
})
@ -215,7 +215,7 @@ describe('v-on', () => {
// in this case the return value is discarded and the behavior is
// consistent with 2.x
expect(code).contains(
'_on(n1, "click", () => $event => {_ctx.foo();_ctx.bar()})',
'_on(n0, "click", () => $event => {_ctx.foo();_ctx.bar()})',
)
})
@ -234,7 +234,7 @@ describe('v-on', () => {
// in this case the return value is discarded and the behavior is
// consistent with 2.x
expect(code).contains(
'_on(n1, "click", () => $event => {\n_ctx.foo();\n_ctx.bar()\n})',
'_on(n0, "click", () => $event => {\n_ctx.foo();\n_ctx.bar()\n})',
)
})
@ -253,7 +253,7 @@ describe('v-on', () => {
expect(code).matchSnapshot()
// should NOT prefix $event
expect(code).contains(
'_on(n1, "click", () => $event => (_ctx.foo($event)))',
'_on(n0, "click", () => $event => (_ctx.foo($event)))',
)
})
@ -272,7 +272,7 @@ describe('v-on', () => {
expect(code).matchSnapshot()
// should NOT prefix $event
expect(code).contains(
'_on(n1, "click", () => $event => {_ctx.foo($event);_ctx.bar()})',
'_on(n0, "click", () => $event => {_ctx.foo($event);_ctx.bar()})',
)
})
@ -287,7 +287,7 @@ describe('v-on', () => {
])
expect(code).matchSnapshot()
expect(code).contains('_on(n1, "click", () => $event => _ctx.foo($event))')
expect(code).contains('_on(n0, "click", () => $event => _ctx.foo($event))')
})
test('should NOT wrap as function if expression is already function expression (with Typescript)', () => {
@ -305,7 +305,7 @@ describe('v-on', () => {
expect(code).matchSnapshot()
expect(code).contains(
'_on(n1, "click", () => (e: any): any => _ctx.foo(e))',
'_on(n0, "click", () => (e: any): any => _ctx.foo(e))',
)
})
@ -372,7 +372,7 @@ describe('v-on', () => {
])
expect(code).matchSnapshot()
expect(code).contains(`_on(n1, "click", () => _ctx.a['b' + _ctx.c])`)
expect(code).contains(`_on(n0, "click", () => _ctx.a['b' + _ctx.c])`)
})
test('function expression w/ prefixIdentifiers: true', () => {
@ -388,7 +388,7 @@ describe('v-on', () => {
])
expect(code).matchSnapshot()
expect(code).contains('_on(n1, "click", () => e => _ctx.foo(e))')
expect(code).contains('_on(n0, "click", () => e => _ctx.foo(e))')
})
test('should error if no expression AND no modifier', () => {
@ -494,10 +494,10 @@ describe('v-on', () => {
])
expect(code).matchSnapshot()
expect(code).contains(`_on(n1, "click", () => _ctx.test, undefined`)
expect(code).contains(`_on(n0, "click", () => _ctx.test, undefined`)
expect(code).contains(`modifiers: ["stop"]`)
expect(code).contains(`_on(n1, "keyup", () => _ctx.test, undefined`)
expect(code).contains(`_on(n0, "keyup", () => _ctx.test, undefined`)
expect(code).contains(`keys: ["enter"]`)
})
@ -512,7 +512,7 @@ describe('v-on', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_EVENT,
element: 1,
element: 0,
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'keydown',
@ -680,6 +680,6 @@ describe('v-on', () => {
})
expect(code).matchSnapshot()
expect(code).contains(`_on(n1, "click", () => _ctx.foo.bar)`)
expect(code).contains(`_on(n0, "click", () => _ctx.foo.bar)`)
})
})

View File

@ -30,10 +30,10 @@ describe('compiler: v-once', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.CREATE_TEXT_NODE,
id: 1,
id: 0,
},
{
element: 1,
element: 0,
type: IRNodeTypes.SET_TEXT,
values: [
{
@ -49,7 +49,7 @@ describe('compiler: v-once', () => {
],
},
{
element: 2,
element: 1,
type: IRNodeTypes.SET_PROP,
prop: {
key: {
@ -68,8 +68,8 @@ describe('compiler: v-once', () => {
},
{
type: IRNodeTypes.PREPEND_NODE,
elements: [1],
parent: 3,
elements: [0],
parent: 2,
},
])
})
@ -83,7 +83,7 @@ describe('compiler: v-once', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_PROP,
element: 1,
element: 0,
prop: {
key: {
type: NodeTypes.SIMPLE_EXPRESSION,
@ -114,7 +114,7 @@ describe('compiler: v-once', () => {
expect(ir.block.operation).toMatchObject([
{
type: IRNodeTypes.SET_PROP,
element: 1,
element: 0,
prop: {
runtimeCamelize: false,
key: {

View File

@ -42,7 +42,7 @@ describe('v-text', () => {
operations: [
{
type: IRNodeTypes.SET_TEXT,
element: 1,
element: 0,
values: [
{
type: NodeTypes.SIMPLE_EXPRESSION,
@ -82,7 +82,7 @@ describe('v-text', () => {
operations: [
{
type: IRNodeTypes.SET_TEXT,
element: 1,
element: 0,
values: [
{
type: NodeTypes.SIMPLE_EXPRESSION,

View File

@ -195,7 +195,6 @@ function createRootContext(
},
}
context.root = context
context.reference()
return context
}