mirror of https://github.com/vuejs/core.git
refactor(compiler-vapor): generate fragment for only one element
closes #133
This commit is contained in:
parent
004edd3bac
commit
d7bd6c99da
|
@ -1,110 +1,101 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compile > bindings 1`] = `
|
exports[`compile > bindings 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setText(n1, "count is ", _ctx.count, "."))
|
_renderEffect(() => _setText(n1, "count is ", _ctx.count, "."))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > custom directive > basic 1`] = `
|
exports[`compile > custom directive > basic 1`] = `
|
||||||
"import { children as _children, resolveDirective as _resolveDirective, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { resolveDirective as _resolveDirective, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_resolveDirective("vTest")], [_resolveDirective("vHello"), void 0, void 0, { world: true }]])
|
_withDirectives(n1, [[_resolveDirective("vTest")], [_resolveDirective("vHello"), void 0, void 0, { world: true }]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > basic 1`] = `
|
exports[`compile > directives > custom directive > basic 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample]])
|
_withDirectives(n1, [[_ctx.vExample]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > binding value 1`] = `
|
exports[`compile > directives > custom directive > binding value 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg]])
|
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > dynamic parameters 1`] = `
|
exports[`compile > directives > custom directive > dynamic parameters 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, _ctx.foo]])
|
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, _ctx.foo]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > modifiers 1`] = `
|
exports[`compile > directives > custom directive > modifiers 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, void 0, { bar: true }]])
|
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, void 0, { bar: true }]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > modifiers w/o binding 1`] = `
|
exports[`compile > directives > custom directive > modifiers w/o binding 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, void 0, void 0, { "foo-bar": true }]])
|
_withDirectives(n1, [[_ctx.vExample, void 0, void 0, { "foo-bar": true }]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > static parameters 1`] = `
|
exports[`compile > directives > custom directive > static parameters 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo"]])
|
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo"]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > custom directive > static parameters and modifiers 1`] = `
|
exports[`compile > directives > custom directive > static parameters and modifiers 1`] = `
|
||||||
"import { children as _children, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo", { bar: true }]])
|
_withDirectives(n1, [[_ctx.vExample, () => _ctx.msg, "foo", { bar: true }]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -113,8 +104,8 @@ exports[`compile > directives > v-cloak > basic 1`] = `
|
||||||
const t0 = _template("<div>test</div>")
|
const t0 = _template("<div>test</div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -123,38 +114,24 @@ exports[`compile > directives > v-pre > basic 1`] = `
|
||||||
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
|
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`compile > directives > v-pre > self-closing v-pre 1`] = `
|
|
||||||
"import { children as _children, createTextNode as _createTextNode, append as _append, renderEffect as _renderEffect, setText as _setText, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
|
||||||
const t0 = _template("<div></div><div><Comp></Comp></div>")
|
|
||||||
|
|
||||||
export function render(_ctx) {
|
|
||||||
const n0 = t0()
|
|
||||||
const n2 = _children(n0, 1)
|
|
||||||
const n1 = _createTextNode()
|
|
||||||
_append(n2, n1)
|
|
||||||
_renderEffect(() => _setText(n1, _ctx.bar))
|
|
||||||
_renderEffect(() => _setDynamicProp(n2, "id", _ctx.foo))
|
|
||||||
return n0
|
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > directives > v-pre > should not affect siblings after it 1`] = `
|
exports[`compile > directives > v-pre > should not affect siblings after it 1`] = `
|
||||||
"import { children as _children, createTextNode as _createTextNode, append as _append, renderEffect as _renderEffect, setText as _setText, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { createTextNode as _createTextNode, append as _append, renderEffect as _renderEffect, setText as _setText, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div><div><Comp></Comp></div>")
|
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div>")
|
||||||
|
const t1 = _template("<div><Comp></Comp></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n2 = _children(n0, 1)
|
const n3 = t1()
|
||||||
const n1 = _createTextNode()
|
const n2 = _createTextNode()
|
||||||
_append(n2, n1)
|
_append(n3, n2)
|
||||||
_renderEffect(() => _setText(n1, _ctx.bar))
|
_renderEffect(() => _setText(n2, _ctx.bar))
|
||||||
_renderEffect(() => _setDynamicProp(n2, "id", _ctx.foo))
|
_renderEffect(() => _setDynamicProp(n3, "id", _ctx.foo))
|
||||||
return n0
|
return [n1, n3]
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -169,16 +146,15 @@ export function render(_ctx) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > dynamic root nodes and interpolation 1`] = `
|
exports[`compile > dynamic root nodes and interpolation 1`] = `
|
||||||
"import { children as _children, on as _on, renderEffect as _renderEffect, setText as _setText, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { on as _on, renderEffect as _renderEffect, setText as _setText, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<button></button>")
|
const t0 = _template("<button></button>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.handleClick)
|
_on(n1, "click", () => _ctx.handleClick)
|
||||||
_renderEffect(() => _setText(n1, _ctx.count, "foo", _ctx.count, "foo", _ctx.count))
|
_renderEffect(() => _setText(n1, _ctx.count, "foo", _ctx.count, "foo", _ctx.count))
|
||||||
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.count))
|
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.count))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -192,20 +168,23 @@ exports[`compile > expression parsing > interpolation 1`] = `
|
||||||
|
|
||||||
exports[`compile > expression parsing > v-bind 1`] = `
|
exports[`compile > expression parsing > v-bind 1`] = `
|
||||||
"(() => {
|
"(() => {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { [key.value+1]: _unref(foo)[key.value+1]() }))
|
_renderEffect(() => _setDynamicProps(n1, { [key.value+1]: _unref(foo)[key.value+1]() }))
|
||||||
return n0
|
return n1
|
||||||
})()"
|
})()"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compile > fragment 1`] = `
|
exports[`compile > fragment 1`] = `
|
||||||
"import { template as _template } from 'vue/vapor';
|
"import { template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<p></p><span></span><div></div>")
|
const t0 = _template("<p></p>")
|
||||||
|
const t1 = _template("<span></span>")
|
||||||
|
const t2 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
const n2 = t1()
|
||||||
|
const n3 = t2()
|
||||||
|
return [n1, n2, n3]
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -224,7 +203,7 @@ exports[`compile > static template 1`] = `
|
||||||
const t0 = _template("<div><p>hello</p><input><span></span></div>")
|
const t0 = _template("<div><p>hello</p><input><span></span></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -88,17 +88,6 @@ describe('compile', () => {
|
||||||
expect(code).toMatchSnapshot()
|
expect(code).toMatchSnapshot()
|
||||||
// Waiting for TODO, There should be more here.
|
// Waiting for TODO, There should be more here.
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: support multiple root nodes and components
|
|
||||||
test('self-closing v-pre', () => {
|
|
||||||
const code = compile(
|
|
||||||
`<div v-pre/>\n<div :id="foo"><Comp/>{{ bar }}</div>`,
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(code).toMatchSnapshot()
|
|
||||||
expect(code).contains('<div></div><div><Comp></Comp></div>')
|
|
||||||
// Waiting for TODO, There should be more here.
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('v-cloak', () => {
|
describe('v-cloak', () => {
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: element transform > props merging: class 1`] = `
|
exports[`compiler: element transform > props merging: class 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setClass as _setClass, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setClass as _setClass, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setClass(n1, ["foo", { bar: _ctx.isBar }]))
|
_renderEffect(() => _setClass(n1, ["foo", { bar: _ctx.isBar }]))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > props merging: style 1`] = `
|
exports[`compiler: element transform > props merging: style 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setStyle as _setStyle, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setStyle as _setStyle, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setStyle(n1, ["color: green", { color: 'red' }]))
|
_renderEffect(() => _setStyle(n1, ["color: green", { color: 'red' }]))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -29,55 +27,51 @@ exports[`compiler: element transform > static props 1`] = `
|
||||||
const t0 = _template("<div id=\\"foo\\" class=\\"bar\\"></div>")
|
const t0 = _template("<div id=\\"foo\\" class=\\"bar\\"></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > v-bind="obj" 1`] = `
|
exports[`compiler: element transform > v-bind="obj" 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
|
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > v-bind="obj" after static prop 1`] = `
|
exports[`compiler: element transform > v-bind="obj" after static prop 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj))
|
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > v-bind="obj" before static prop 1`] = `
|
exports[`compiler: element transform > v-bind="obj" before static prop 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, _ctx.obj, { id: "foo" }))
|
_renderEffect(() => _setDynamicProps(n1, _ctx.obj, { id: "foo" }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > v-bind="obj" between static props 1`] = `
|
exports[`compiler: element transform > v-bind="obj" between static props 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj, { class: "bar" }))
|
_renderEffect(() => _setDynamicProps(n1, { id: "foo" }, _ctx.obj, { class: "bar" }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,183 +1,168 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler v-bind > .attr modifier 1`] = `
|
exports[`compiler v-bind > .attr modifier 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setAttr as _setAttr, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setAttr as _setAttr, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.id))
|
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .attr modifier w/ no expression 1`] = `
|
exports[`compiler v-bind > .attr modifier w/ no expression 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setAttr as _setAttr, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setAttr as _setAttr, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.fooBar))
|
_renderEffect(() => _setAttr(n1, "foo-bar", _ctx.fooBar))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .camel modifier 1`] = `
|
exports[`compiler v-bind > .camel modifier 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.id))
|
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .camel modifier w/ dynamic arg 1`] = `
|
exports[`compiler v-bind > .camel modifier w/ dynamic arg 1`] = `
|
||||||
"import { camelize as _camelize } from 'vue';
|
"import { camelize as _camelize } from 'vue';
|
||||||
import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { [_camelize(_ctx.foo)]: _ctx.id }))
|
_renderEffect(() => _setDynamicProps(n1, { [_camelize(_ctx.foo)]: _ctx.id }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .camel modifier w/ no expression 1`] = `
|
exports[`compiler v-bind > .camel modifier w/ no expression 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.fooBar))
|
_renderEffect(() => _setDynamicProp(n1, "fooBar", _ctx.fooBar))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .prop modifier (shortband) w/ no expression 1`] = `
|
exports[`compiler v-bind > .prop modifier (shortband) w/ no expression 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
|
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .prop modifier (shorthand) 1`] = `
|
exports[`compiler v-bind > .prop modifier (shorthand) 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
|
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .prop modifier 1`] = `
|
exports[`compiler v-bind > .prop modifier 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
|
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .prop modifier w/ dynamic arg 1`] = `
|
exports[`compiler v-bind > .prop modifier w/ dynamic arg 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { ["." + _ctx.fooBar]: _ctx.id }))
|
_renderEffect(() => _setDynamicProps(n1, { ["." + _ctx.fooBar]: _ctx.id }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > .prop modifier w/ no expression 1`] = `
|
exports[`compiler v-bind > .prop modifier w/ no expression 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDOMProp as _setDOMProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
|
_renderEffect(() => _setDOMProp(n1, "fooBar", _ctx.fooBar))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > basic 1`] = `
|
exports[`compiler v-bind > basic 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
|
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > dynamic arg 1`] = `
|
exports[`compiler v-bind > dynamic arg 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title }))
|
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, [_ctx.title]: _ctx.title }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > dynamic arg w/ static attribute 1`] = `
|
exports[`compiler v-bind > dynamic arg w/ static attribute 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" }))
|
_renderEffect(() => _setDynamicProps(n1, { [_ctx.id]: _ctx.id, foo: "bar", checked: "" }))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > no expression (shorthand) 1`] = `
|
exports[`compiler v-bind > no expression (shorthand) 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProp(n1, "camel-case", _ctx.camelCase))
|
_renderEffect(() => _setDynamicProp(n1, "camel-case", _ctx.camelCase))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler v-bind > no expression 1`] = `
|
exports[`compiler v-bind > no expression 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
|
_renderEffect(() => _setDynamicProp(n1, "id", _ctx.id))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -186,7 +171,7 @@ exports[`compiler v-bind > should error if empty expression 1`] = `
|
||||||
const t0 = _template("<div arg></div>")
|
const t0 = _template("<div arg></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,40 +1,38 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: v-for > basic v-for 1`] = `
|
exports[`compiler: v-for > basic v-for 1`] = `
|
||||||
"import { children as _children, on as _on, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue/vapor';
|
"import { on as _on, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
const n3 = _children(n2, 0)
|
|
||||||
_on(n3, "click", () => $event => (_ctx.remove(_block.s[0])))
|
_on(n3, "click", () => $event => (_ctx.remove(_block.s[0])))
|
||||||
const _updateEffect = () => {
|
const _updateEffect = () => {
|
||||||
const [item] = _block.s
|
const [item] = _block.s
|
||||||
_setText(n3, item)
|
_setText(n3, item)
|
||||||
}
|
}
|
||||||
_renderEffect(_updateEffect)
|
_renderEffect(_updateEffect)
|
||||||
return [n2, _updateEffect]
|
return [n3, _updateEffect]
|
||||||
}, (item) => (item.id))
|
}, (item) => (item.id))
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: v-for > multi effect 1`] = `
|
exports[`compiler: v-for > multi effect 1`] = `
|
||||||
"import { children as _children, setDynamicProp as _setDynamicProp, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue/vapor';
|
"import { setDynamicProp as _setDynamicProp, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
const n3 = _children(n2, 0)
|
|
||||||
const _updateEffect = () => {
|
const _updateEffect = () => {
|
||||||
const [item, index] = _block.s
|
const [item, index] = _block.s
|
||||||
_setDynamicProp(n3, "item", item)
|
_setDynamicProp(n3, "item", item)
|
||||||
_setDynamicProp(n3, "index", index)
|
_setDynamicProp(n3, "index", index)
|
||||||
}
|
}
|
||||||
_renderEffect(_updateEffect)
|
_renderEffect(_updateEffect)
|
||||||
return [n2, _updateEffect]
|
return [n3, _updateEffect]
|
||||||
})
|
})
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
@ -46,8 +44,8 @@ const t0 = _template("<div>item</div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
const n1 = _createFor(() => (_ctx.items), (_block) => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return [n2, () => {}]
|
return [n3, () => {}]
|
||||||
})
|
})
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -1,37 +1,34 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`v-html > should convert v-html to innerHTML 1`] = `
|
exports[`v-html > should convert v-html to innerHTML 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setHtml as _setHtml, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setHtml as _setHtml, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setHtml(n1, _ctx.code))
|
_renderEffect(() => _setHtml(n1, _ctx.code))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-html > should raise error and ignore children when v-html is present 1`] = `
|
exports[`v-html > should raise error and ignore children when v-html is present 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setHtml as _setHtml, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setHtml as _setHtml, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setHtml(n1, _ctx.test))
|
_renderEffect(() => _setHtml(n1, _ctx.test))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-html > should raise error if has no expression 1`] = `
|
exports[`v-html > should raise error if has no expression 1`] = `
|
||||||
"import { children as _children, setHtml as _setHtml, template as _template } from 'vue/vapor';
|
"import { setHtml as _setHtml, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_setHtml(n1, "")
|
_setHtml(n1, "")
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,43 +1,44 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: v-if > basic v-if 1`] = `
|
exports[`compiler: v-if > basic v-if 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setText as _setText, createIf as _createIf, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setText as _setText, createIf as _createIf, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
const n3 = _children(n2, 0)
|
|
||||||
_renderEffect(() => _setText(n3, _ctx.msg))
|
_renderEffect(() => _setText(n3, _ctx.msg))
|
||||||
return n2
|
return n3
|
||||||
})
|
})
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: v-if > comment between branches 1`] = `
|
exports[`compiler: v-if > comment between branches 1`] = `
|
||||||
"import { children as _children, createIf as _createIf, prepend as _prepend, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
"import { createIf as _createIf, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
const t1 = _template("<!--foo--><p></p>")
|
const t1 = _template("<!--foo-->")
|
||||||
const t2 = _template("<!--bar-->fine")
|
const t2 = _template("<p></p>")
|
||||||
const t3 = _template("<input>")
|
const t3 = _template("<!--bar-->")
|
||||||
|
const t4 = _template("fine")
|
||||||
|
const t5 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t3()
|
const n14 = t5()
|
||||||
const n5 = _children(n0, 0)
|
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return n2
|
|
||||||
}, () => _createIf(() => (_ctx.orNot), () => {
|
|
||||||
const n3 = t1()
|
|
||||||
return n3
|
return n3
|
||||||
|
}, () => _createIf(() => (_ctx.orNot), () => {
|
||||||
|
const n6 = t1()
|
||||||
|
const n7 = t2()
|
||||||
|
return [n6, n7]
|
||||||
}, () => {
|
}, () => {
|
||||||
const n4 = t2()
|
const n11 = t3()
|
||||||
return n4
|
const n12 = t4()
|
||||||
|
return [n11, n12]
|
||||||
}))
|
}))
|
||||||
_prepend(n0, n1)
|
_renderEffect(() => _setText(n14, _ctx.text))
|
||||||
_renderEffect(() => _setText(n5, _ctx.text))
|
return [n1, n14]
|
||||||
return n0
|
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -47,27 +48,30 @@ const t0 = _template("<div>hello</div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return n2
|
return n3
|
||||||
})
|
})
|
||||||
const n3 = _createIf(() => (_ctx.ok), () => {
|
const n4 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n4 = t0()
|
const n6 = t0()
|
||||||
return n4
|
return n6
|
||||||
})
|
})
|
||||||
return [n1, n3]
|
return [n1, n4]
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: v-if > template v-if 1`] = `
|
exports[`compiler: v-if > template v-if 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setText as _setText, createIf as _createIf, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setText as _setText, createIf as _createIf, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>hello<p></p>")
|
const t0 = _template("<div></div>")
|
||||||
|
const t1 = _template("hello")
|
||||||
|
const t2 = _template("<p></p>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
const n3 = _children(n2, 2)
|
const n4 = t1()
|
||||||
_renderEffect(() => _setText(n3, _ctx.msg))
|
const n5 = t2()
|
||||||
return n2
|
_renderEffect(() => _setText(n5, _ctx.msg))
|
||||||
|
return [n3, n4, n5]
|
||||||
})
|
})
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
@ -80,11 +84,11 @@ const t1 = _template("<p></p>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return n2
|
|
||||||
}, () => {
|
|
||||||
const n3 = t1()
|
|
||||||
return n3
|
return n3
|
||||||
|
}, () => {
|
||||||
|
const n5 = t1()
|
||||||
|
return n5
|
||||||
})
|
})
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
@ -98,14 +102,14 @@ const t2 = _template("fine")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return n2
|
|
||||||
}, () => _createIf(() => (_ctx.orNot), () => {
|
|
||||||
const n3 = t1()
|
|
||||||
return n3
|
return n3
|
||||||
|
}, () => _createIf(() => (_ctx.orNot), () => {
|
||||||
|
const n5 = t1()
|
||||||
|
return n5
|
||||||
}, () => {
|
}, () => {
|
||||||
const n4 = t2()
|
const n8 = t2()
|
||||||
return n4
|
return n8
|
||||||
}))
|
}))
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
@ -118,11 +122,11 @@ const t1 = _template("<p></p>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n1 = _createIf(() => (_ctx.ok), () => {
|
const n1 = _createIf(() => (_ctx.ok), () => {
|
||||||
const n2 = t0()
|
const n3 = t0()
|
||||||
return n2
|
|
||||||
}, () => _createIf(() => (_ctx.orNot), () => {
|
|
||||||
const n3 = t1()
|
|
||||||
return n3
|
return n3
|
||||||
|
}, () => _createIf(() => (_ctx.orNot), () => {
|
||||||
|
const n5 = t1()
|
||||||
|
return n5
|
||||||
}))
|
}))
|
||||||
return n1
|
return n1
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -1,158 +1,146 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: vModel transform > modifiers > .lazy 1`] = `
|
exports[`compiler: vModel transform > modifiers > .lazy 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { lazy: true }]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { lazy: true }]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > modifiers > .number 1`] = `
|
exports[`compiler: vModel transform > modifiers > .number 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { number: true }]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { number: true }]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > modifiers > .trim 1`] = `
|
exports[`compiler: vModel transform > modifiers > .trim 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { trim: true }]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model, void 0, { trim: true }]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support input (checkbox) 1`] = `
|
exports[`compiler: vModel transform > should support input (checkbox) 1`] = `
|
||||||
"import { children as _children, vModelCheckbox as _vModelCheckbox, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelCheckbox as _vModelCheckbox, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input type=\\"checkbox\\">")
|
const t0 = _template("<input type=\\"checkbox\\">")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelCheckbox, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelCheckbox, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support input (dynamic type) 1`] = `
|
exports[`compiler: vModel transform > should support input (dynamic type) 1`] = `
|
||||||
"import { children as _children, vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support input (radio) 1`] = `
|
exports[`compiler: vModel transform > should support input (radio) 1`] = `
|
||||||
"import { children as _children, vModelRadio as _vModelRadio, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelRadio as _vModelRadio, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input type=\\"radio\\">")
|
const t0 = _template("<input type=\\"radio\\">")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelRadio, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelRadio, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support input (text) 1`] = `
|
exports[`compiler: vModel transform > should support input (text) 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input type=\\"text\\">")
|
const t0 = _template("<input type=\\"text\\">")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support select 1`] = `
|
exports[`compiler: vModel transform > should support select 1`] = `
|
||||||
"import { children as _children, vModelSelect as _vModelSelect, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelSelect as _vModelSelect, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<select></select>")
|
const t0 = _template("<select></select>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelSelect, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelSelect, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support simple expression 1`] = `
|
exports[`compiler: vModel transform > should support simple expression 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support textarea 1`] = `
|
exports[`compiler: vModel transform > should support textarea 1`] = `
|
||||||
"import { children as _children, vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelText as _vModelText, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<textarea></textarea>")
|
const t0 = _template("<textarea></textarea>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelText, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support w/ dynamic v-bind 1`] = `
|
exports[`compiler: vModel transform > should support w/ dynamic v-bind 1`] = `
|
||||||
"import { children as _children, vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
|
_renderEffect(() => _setDynamicProps(n1, _ctx.obj))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: vModel transform > should support w/ dynamic v-bind 2`] = `
|
exports[`compiler: vModel transform > should support w/ dynamic v-bind 2`] = `
|
||||||
"import { children as _children, vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
"import { vModelDynamic as _vModelDynamic, withDirectives as _withDirectives, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<input>")
|
const t0 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
_withDirectives(n1, [[_vModelDynamic, () => _ctx.model]])
|
||||||
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
_on(n1, "update:modelValue", $event => (_ctx.model = $event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,81 +1,79 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
|
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > dynamic arg 1`] = `
|
exports[`v-on > dynamic arg 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
|
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > dynamic arg with complex exp prefixing 1`] = `
|
exports[`v-on > dynamic arg with complex exp prefixing 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _on(n1, _ctx.event(_ctx.foo), () => _ctx.handler))
|
_renderEffect(() => _on(n1, _ctx.event(_ctx.foo), () => _ctx.handler))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > dynamic arg with prefixing 1`] = `
|
exports[`v-on > dynamic arg with prefixing 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
|
_renderEffect(() => _on(n1, _ctx.event, () => _ctx.handler))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > event modifier 1`] = `
|
exports[`v-on > event modifier 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<a></a><form></form><a></a><div></div><div></div><a></a><div></div><input><input><input><input><input><input><input><input><input><input><input><input><input><input><input>")
|
const t0 = _template("<a></a>")
|
||||||
|
const t1 = _template("<form></form>")
|
||||||
|
const t2 = _template("<div></div>")
|
||||||
|
const t3 = _template("<input>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
const n2 = t1()
|
||||||
const n2 = _children(n0, 1)
|
const n3 = t0()
|
||||||
const n3 = _children(n0, 2)
|
const n4 = t2()
|
||||||
const n4 = _children(n0, 3)
|
const n5 = t2()
|
||||||
const n5 = _children(n0, 4)
|
const n6 = t0()
|
||||||
const n6 = _children(n0, 5)
|
const n7 = t2()
|
||||||
const n7 = _children(n0, 6)
|
const n8 = t3()
|
||||||
const n8 = _children(n0, 7)
|
const n9 = t3()
|
||||||
const n9 = _children(n0, 8)
|
const n10 = t3()
|
||||||
const n10 = _children(n0, 9)
|
const n11 = t3()
|
||||||
const n11 = _children(n0, 10)
|
const n12 = t3()
|
||||||
const n12 = _children(n0, 11)
|
const n13 = t3()
|
||||||
const n13 = _children(n0, 12)
|
const n14 = t3()
|
||||||
const n14 = _children(n0, 13)
|
const n15 = t3()
|
||||||
const n15 = _children(n0, 14)
|
const n16 = t3()
|
||||||
const n16 = _children(n0, 15)
|
const n17 = t3()
|
||||||
const n17 = _children(n0, 16)
|
const n18 = t3()
|
||||||
const n18 = _children(n0, 17)
|
const n19 = t3()
|
||||||
const n19 = _children(n0, 18)
|
const n20 = t3()
|
||||||
const n20 = _children(n0, 19)
|
const n21 = t3()
|
||||||
const n21 = _children(n0, 20)
|
const n22 = t3()
|
||||||
const n22 = _children(n0, 21)
|
|
||||||
_on(n1, "click", () => _ctx.handleEvent, undefined, {
|
_on(n1, "click", () => _ctx.handleEvent, undefined, {
|
||||||
modifiers: ["stop"]
|
modifiers: ["stop"]
|
||||||
})
|
})
|
||||||
|
@ -137,334 +135,310 @@ export function render(_ctx) {
|
||||||
modifiers: ["self"],
|
modifiers: ["self"],
|
||||||
keys: ["enter"]
|
keys: ["enter"]
|
||||||
})
|
})
|
||||||
return n0
|
return [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22]
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > function expression w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > function expression w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => e => _ctx.foo(e))
|
_on(n1, "click", () => e => _ctx.foo(e))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > inline statement w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > inline statement w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => (_ctx.foo($event)))
|
_on(n1, "click", () => $event => (_ctx.foo($event)))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > multiple inline statements w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > multiple inline statements w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => {_ctx.foo($event);_ctx.bar()})
|
_on(n1, "click", () => $event => {_ctx.foo($event);_ctx.bar()})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should NOT add a prefix to $event if the expression is a function expression 1`] = `
|
exports[`v-on > should NOT add a prefix to $event if the expression is a function expression 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => {_ctx.i++;_ctx.foo($event)})
|
_on(n1, "click", () => $event => {_ctx.i++;_ctx.foo($event)})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should NOT wrap as function if expression is already function expression (with Typescript) 1`] = `
|
exports[`v-on > should NOT wrap as function if expression is already function expression (with Typescript) 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => (e: any): any => _ctx.foo(e))
|
_on(n1, "click", () => (e: any): any => _ctx.foo(e))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should NOT wrap as function if expression is already function expression (with newlines) 1`] = `
|
exports[`v-on > should NOT wrap as function if expression is already function expression (with newlines) 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () =>
|
_on(n1, "click", () =>
|
||||||
$event => {
|
$event => {
|
||||||
_ctx.foo($event)
|
_ctx.foo($event)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should NOT wrap as function if expression is already function expression 1`] = `
|
exports[`v-on > should NOT wrap as function if expression is already function expression 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => _ctx.foo($event))
|
_on(n1, "click", () => $event => _ctx.foo($event))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should NOT wrap as function if expression is complex member expression 1`] = `
|
exports[`v-on > should NOT wrap as function if expression is complex member expression 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
|
_on(n1, "click", () => _ctx.a['b' + _ctx.c])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should handle multi-line statement 1`] = `
|
exports[`v-on > should handle multi-line statement 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => {
|
_on(n1, "click", () => $event => {
|
||||||
_ctx.foo();
|
_ctx.foo();
|
||||||
_ctx.bar()
|
_ctx.bar()
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should handle multiple inline statement 1`] = `
|
exports[`v-on > should handle multiple inline statement 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => {_ctx.foo();_ctx.bar()})
|
_on(n1, "click", () => $event => {_ctx.foo();_ctx.bar()})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should not prefix member expression 1`] = `
|
exports[`v-on > should not prefix member expression 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.foo.bar)
|
_on(n1, "click", () => _ctx.foo.bar)
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
|
exports[`v-on > should not wrap keys guard if no key modifier is present 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "keyup", () => _ctx.test, undefined, {
|
_on(n1, "keyup", () => _ctx.test, undefined, {
|
||||||
modifiers: ["exact"]
|
modifiers: ["exact"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should support multiple events and modifiers options w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > should support multiple events and modifiers options w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.test, undefined, {
|
_on(n1, "click", () => _ctx.test, undefined, {
|
||||||
modifiers: ["stop"]
|
modifiers: ["stop"]
|
||||||
})
|
})
|
||||||
_on(n1, "keyup", () => _ctx.test, undefined, {
|
_on(n1, "keyup", () => _ctx.test, undefined, {
|
||||||
keys: ["enter"]
|
keys: ["enter"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should support multiple modifiers and event options w/ prefixIdentifiers: true 1`] = `
|
exports[`v-on > should support multiple modifiers and event options w/ prefixIdentifiers: true 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.test, { capture: true, once: true }, {
|
_on(n1, "click", () => _ctx.test, { capture: true, once: true }, {
|
||||||
modifiers: ["stop", "prevent"]
|
modifiers: ["stop", "prevent"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should transform click.middle 1`] = `
|
exports[`v-on > should transform click.middle 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "mouseup", () => _ctx.test, undefined, {
|
_on(n1, "mouseup", () => _ctx.test, undefined, {
|
||||||
modifiers: ["middle"]
|
modifiers: ["middle"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should transform click.middle 2`] = `
|
exports[`v-on > should transform click.middle 2`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => {
|
_renderEffect(() => {
|
||||||
_on(n1, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, {
|
_on(n1, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, {
|
||||||
modifiers: ["middle"]
|
modifiers: ["middle"]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should transform click.right 1`] = `
|
exports[`v-on > should transform click.right 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "contextmenu", () => _ctx.test, undefined, {
|
_on(n1, "contextmenu", () => _ctx.test, undefined, {
|
||||||
modifiers: ["right"]
|
modifiers: ["right"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should transform click.right 2`] = `
|
exports[`v-on > should transform click.right 2`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => {
|
_renderEffect(() => {
|
||||||
_on(n1, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, {
|
_on(n1, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, {
|
||||||
modifiers: ["right"],
|
modifiers: ["right"],
|
||||||
keys: ["right"]
|
keys: ["right"]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should wrap as function if expression is inline statement 1`] = `
|
exports[`v-on > should wrap as function if expression is inline statement 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => $event => (_ctx.i++))
|
_on(n1, "click", () => $event => (_ctx.i++))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should wrap both for dynamic key event w/ left/right modifiers 1`] = `
|
exports[`v-on > should wrap both for dynamic key event w/ left/right modifiers 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => {
|
_renderEffect(() => {
|
||||||
_on(n1, _ctx.e, () => _ctx.test, undefined, {
|
_on(n1, _ctx.e, () => _ctx.test, undefined, {
|
||||||
modifiers: ["left"],
|
modifiers: ["left"],
|
||||||
keys: ["left"]
|
keys: ["left"]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should wrap in unref if identifier is setup-maybe-ref w/ inline: true 1`] = `
|
exports[`v-on > should wrap in unref if identifier is setup-maybe-ref w/ inline: true 1`] = `
|
||||||
"(() => {
|
"(() => {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
const n2 = t0()
|
||||||
const n2 = _children(n0, 1)
|
const n3 = t0()
|
||||||
const n3 = _children(n0, 2)
|
|
||||||
_on(n1, "click", () => $event => (x.value=_unref(y)))
|
_on(n1, "click", () => $event => (x.value=_unref(y)))
|
||||||
_on(n2, "click", () => $event => (x.value++))
|
_on(n2, "click", () => $event => (x.value++))
|
||||||
_on(n3, "click", () => $event => ({ x: x.value } = _unref(y)))
|
_on(n3, "click", () => $event => ({ x: x.value } = _unref(y)))
|
||||||
return n0
|
return [n1, n2, n3]
|
||||||
})()"
|
})()"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should wrap keys guard for keyboard events or dynamic events 1`] = `
|
exports[`v-on > should wrap keys guard for keyboard events or dynamic events 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "keydown", () => _ctx.test, { capture: true }, {
|
_on(n1, "keydown", () => _ctx.test, { capture: true }, {
|
||||||
modifiers: ["stop", "ctrl"],
|
modifiers: ["stop", "ctrl"],
|
||||||
keys: ["a"]
|
keys: ["a"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > should wrap keys guard for static key event w/ left/right modifiers 1`] = `
|
exports[`v-on > should wrap keys guard for static key event w/ left/right modifiers 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "keyup", () => _ctx.test, undefined, {
|
_on(n1, "keyup", () => _ctx.test, undefined, {
|
||||||
keys: ["left"]
|
keys: ["left"]
|
||||||
})
|
})
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-on > simple expression 1`] = `
|
exports[`v-on > simple expression 1`] = `
|
||||||
"import { children as _children, on as _on, template as _template } from 'vue/vapor';
|
"import { on as _on, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_on(n1, "click", () => _ctx.handleClick)
|
_on(n1, "click", () => _ctx.handleClick)
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: v-once > as root node 1`] = `
|
exports[`compiler: v-once > as root node 1`] = `
|
||||||
"import { children as _children, setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
"import { setDynamicProp as _setDynamicProp, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_setDynamicProp(n1, "id", _ctx.foo)
|
_setDynamicProp(n1, "id", _ctx.foo)
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -17,14 +16,13 @@ exports[`compiler: v-once > basic 1`] = `
|
||||||
const t0 = _template("<div><span></span></div>")
|
const t0 = _template("<div><span></span></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n3 = t0()
|
||||||
const n3 = _children(n0, 0)
|
|
||||||
const n2 = _children(n3, 0)
|
const n2 = _children(n3, 0)
|
||||||
const n1 = _createTextNode()
|
const n1 = _createTextNode()
|
||||||
_setText(n1, _ctx.msg, " ")
|
_setText(n1, _ctx.msg, " ")
|
||||||
_setClass(n2, _ctx.clz)
|
_setClass(n2, _ctx.clz)
|
||||||
_prepend(n3, n1)
|
_prepend(n3, n1)
|
||||||
return n0
|
return n3
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -33,8 +31,8 @@ exports[`compiler: v-once > inside v-once 1`] = `
|
||||||
const t0 = _template("<div><div></div></div>")
|
const t0 = _template("<div><div></div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -43,9 +41,9 @@ exports[`compiler: v-once > on nested plain element 1`] = `
|
||||||
const t0 = _template("<div><div></div></div>")
|
const t0 = _template("<div><div></div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n2 = t0()
|
||||||
const n1 = _children(n0, 0, 0)
|
const n1 = _children(n2, 0)
|
||||||
_setDynamicProp(n1, "id", _ctx.foo)
|
_setDynamicProp(n1, "id", _ctx.foo)
|
||||||
return n0
|
return n2
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`compiler: v-show transform > simple expression 1`] = `
|
exports[`compiler: v-show transform > simple expression 1`] = `
|
||||||
"import { children as _children, vShow as _vShow, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
"import { vShow as _vShow, withDirectives as _withDirectives, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_withDirectives(n1, [[_vShow, () => _ctx.foo]])
|
_withDirectives(n1, [[_vShow, () => _ctx.foo]])
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,37 +1,34 @@
|
||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`v-text > should convert v-text to textContent 1`] = `
|
exports[`v-text > should convert v-text to textContent 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setText(n1, _ctx.str))
|
_renderEffect(() => _setText(n1, _ctx.str))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-text > should raise error and ignore children when v-text is present 1`] = `
|
exports[`v-text > should raise error and ignore children when v-text is present 1`] = `
|
||||||
"import { children as _children, renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
"import { renderEffect as _renderEffect, setText as _setText, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_renderEffect(() => _setText(n1, _ctx.test))
|
_renderEffect(() => _setText(n1, _ctx.test))
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`v-text > should raise error if has no expression 1`] = `
|
exports[`v-text > should raise error if has no expression 1`] = `
|
||||||
"import { children as _children, setText as _setText, template as _template } from 'vue/vapor';
|
"import { setText as _setText, template as _template } from 'vue/vapor';
|
||||||
const t0 = _template("<div></div>")
|
const t0 = _template("<div></div>")
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const n0 = t0()
|
const n1 = t0()
|
||||||
const n1 = _children(n0, 0)
|
|
||||||
_setText(n1, "")
|
_setText(n1, "")
|
||||||
return n0
|
return n1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
describe('compiler: children transform', () => {
|
||||||
|
test.todo('basic')
|
||||||
|
})
|
|
@ -1,6 +1,7 @@
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
import {
|
import {
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
transformElement,
|
transformElement,
|
||||||
transformVBind,
|
transformVBind,
|
||||||
transformVOn,
|
transformVOn,
|
||||||
|
@ -8,7 +9,7 @@ import {
|
||||||
import { NodeTypes } from '@vue/compiler-core'
|
import { NodeTypes } from '@vue/compiler-core'
|
||||||
|
|
||||||
const compileWithElementTransform = makeCompile({
|
const compileWithElementTransform = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
bind: transformVBind,
|
bind: transformVBind,
|
||||||
on: transformVOn,
|
on: transformVOn,
|
||||||
|
@ -16,7 +17,7 @@ const compileWithElementTransform = makeCompile({
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('compiler: element transform', () => {
|
describe('compiler: element transform', () => {
|
||||||
test.todo('baisc')
|
test.todo('basic')
|
||||||
|
|
||||||
test('static props', () => {
|
test('static props', () => {
|
||||||
const { code, ir } = compileWithElementTransform(
|
const { code, ir } = compileWithElementTransform(
|
||||||
|
|
|
@ -2,13 +2,14 @@ import { ErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
||||||
import {
|
import {
|
||||||
DynamicFlag,
|
DynamicFlag,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
transformElement,
|
transformElement,
|
||||||
transformVBind,
|
transformVBind,
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
|
|
||||||
const compileWithVBind = makeCompile({
|
const compileWithVBind = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
bind: transformVBind,
|
bind: transformVBind,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { makeCompile } from './_utils'
|
||||||
import {
|
import {
|
||||||
type ForIRNode,
|
type ForIRNode,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
transformElement,
|
transformElement,
|
||||||
transformText,
|
transformText,
|
||||||
transformVBind,
|
transformVBind,
|
||||||
|
@ -11,7 +12,12 @@ import {
|
||||||
import { NodeTypes } from '@vue/compiler-dom'
|
import { NodeTypes } from '@vue/compiler-dom'
|
||||||
|
|
||||||
const compileWithVFor = makeCompile({
|
const compileWithVFor = makeCompile({
|
||||||
nodeTransforms: [transformVFor, transformText, transformElement],
|
nodeTransforms: [
|
||||||
|
transformVFor,
|
||||||
|
transformText,
|
||||||
|
transformElement,
|
||||||
|
transformChildren,
|
||||||
|
],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
bind: transformVBind,
|
bind: transformVBind,
|
||||||
on: transformVOn,
|
on: transformVOn,
|
||||||
|
@ -45,7 +51,7 @@ describe('compiler: v-for', () => {
|
||||||
render: {
|
render: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 0,
|
children: [{ template: 0 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
keyProperty: {
|
keyProperty: {
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import { BindingTypes, DOMErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
import { BindingTypes, DOMErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
||||||
import { IRNodeTypes, transformElement, transformVHtml } from '../../src'
|
import {
|
||||||
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
|
transformElement,
|
||||||
|
transformVHtml,
|
||||||
|
} from '../../src'
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
|
|
||||||
const compileWithVHtml = makeCompile({
|
const compileWithVHtml = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
html: transformVHtml,
|
html: transformVHtml,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,8 @@ import { makeCompile } from './_utils'
|
||||||
import {
|
import {
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
type IfIRNode,
|
type IfIRNode,
|
||||||
|
transformChildren,
|
||||||
|
transformComment,
|
||||||
transformElement,
|
transformElement,
|
||||||
transformOnce,
|
transformOnce,
|
||||||
transformText,
|
transformText,
|
||||||
|
@ -16,6 +18,8 @@ const compileWithVIf = makeCompile({
|
||||||
transformVIf,
|
transformVIf,
|
||||||
transformText,
|
transformText,
|
||||||
transformElement,
|
transformElement,
|
||||||
|
transformComment,
|
||||||
|
transformChildren,
|
||||||
],
|
],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
text: transformVText,
|
text: transformVText,
|
||||||
|
@ -44,7 +48,11 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 0,
|
children: [
|
||||||
|
{
|
||||||
|
template: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -68,15 +76,14 @@ describe('compiler: v-if', () => {
|
||||||
)
|
)
|
||||||
expect(code).matchSnapshot()
|
expect(code).matchSnapshot()
|
||||||
|
|
||||||
expect(ir.template).toEqual(['<div></div>hello<p></p>'])
|
expect(ir.template).toEqual(['<div></div>', 'hello', '<p></p>'])
|
||||||
|
|
||||||
expect(ir.block.effect).toEqual([])
|
expect(ir.block.effect).toEqual([])
|
||||||
expect((ir.block.operation[0] as IfIRNode).positive.effect).toMatchObject([
|
expect((ir.block.operation[0] as IfIRNode).positive.effect).toMatchObject([
|
||||||
{
|
{
|
||||||
operations: [
|
operations: [
|
||||||
{
|
{
|
||||||
type: IRNodeTypes.SET_TEXT,
|
type: IRNodeTypes.SET_TEXT,
|
||||||
element: 3,
|
element: 5,
|
||||||
values: [
|
values: [
|
||||||
{
|
{
|
||||||
content: 'msg',
|
content: 'msg',
|
||||||
|
@ -90,7 +97,11 @@ describe('compiler: v-if', () => {
|
||||||
])
|
])
|
||||||
expect((ir.block.operation[0] as IfIRNode).positive.dynamic).toMatchObject({
|
expect((ir.block.operation[0] as IfIRNode).positive.dynamic).toMatchObject({
|
||||||
id: 2,
|
id: 2,
|
||||||
children: { 2: { id: 3 } },
|
children: {
|
||||||
|
2: {
|
||||||
|
id: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -100,7 +111,7 @@ describe('compiler: v-if', () => {
|
||||||
)
|
)
|
||||||
expect(code).matchSnapshot()
|
expect(code).matchSnapshot()
|
||||||
expect(ir.template).toEqual(['<div>hello</div>'])
|
expect(ir.template).toEqual(['<div>hello</div>'])
|
||||||
expect(ir.block.returns).toEqual([1, 3])
|
expect(ir.block.returns).toEqual([1, 4])
|
||||||
})
|
})
|
||||||
|
|
||||||
test.todo('v-if with v-once')
|
test.todo('v-if with v-once')
|
||||||
|
@ -128,13 +139,13 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 0,
|
children: [{ template: 0 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
negative: {
|
negative: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 1,
|
children: [{ template: 1 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -161,7 +172,7 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 0,
|
children: [{ template: 0 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
negative: {
|
negative: {
|
||||||
|
@ -174,7 +185,7 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 1,
|
children: [{ template: 1 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -198,7 +209,7 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 0,
|
children: [{ template: 0 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
negative: {
|
negative: {
|
||||||
|
@ -206,13 +217,13 @@ describe('compiler: v-if', () => {
|
||||||
positive: {
|
positive: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 1,
|
children: [{ template: 1 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
negative: {
|
negative: {
|
||||||
type: IRNodeTypes.BLOCK,
|
type: IRNodeTypes.BLOCK,
|
||||||
dynamic: {
|
dynamic: {
|
||||||
template: 2,
|
children: [{ template: 2 }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -232,8 +243,10 @@ describe('compiler: v-if', () => {
|
||||||
expect(code).matchSnapshot()
|
expect(code).matchSnapshot()
|
||||||
expect(ir.template).toEqual([
|
expect(ir.template).toEqual([
|
||||||
'<div></div>',
|
'<div></div>',
|
||||||
'<!--foo--><p></p>',
|
'<!--foo-->',
|
||||||
'<!--bar-->fine',
|
'<p></p>',
|
||||||
|
'<!--bar-->',
|
||||||
|
'fine',
|
||||||
|
|
||||||
'<input>',
|
'<input>',
|
||||||
])
|
])
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
import { transformElement, transformVModel } from '../../src'
|
import { transformChildren, transformElement, transformVModel } from '../../src'
|
||||||
import { DOMErrorCodes } from '@vue/compiler-dom'
|
import { DOMErrorCodes } from '@vue/compiler-dom'
|
||||||
|
|
||||||
const compileWithVModel = makeCompile({
|
const compileWithVModel = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
model: transformVModel,
|
model: transformVModel,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import { BindingTypes, ErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
import { BindingTypes, ErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
||||||
import { IRNodeTypes, transformElement, transformVOn } from '../../src'
|
import {
|
||||||
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
|
transformElement,
|
||||||
|
transformVOn,
|
||||||
|
} from '../../src'
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
|
|
||||||
const compileWithVOn = makeCompile({
|
const compileWithVOn = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
on: transformVOn,
|
on: transformVOn,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
import { transformElement, transformVShow } from '../../src'
|
import { transformChildren, transformElement, transformVShow } from '../../src'
|
||||||
import { DOMErrorCodes } from '@vue/compiler-dom'
|
import { DOMErrorCodes } from '@vue/compiler-dom'
|
||||||
|
|
||||||
const compileWithVShow = makeCompile({
|
const compileWithVShow = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
show: transformVShow,
|
show: transformVShow,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import { BindingTypes, DOMErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
import { BindingTypes, DOMErrorCodes, NodeTypes } from '@vue/compiler-dom'
|
||||||
import { IRNodeTypes, transformElement, transformVText } from '../../src'
|
import {
|
||||||
|
IRNodeTypes,
|
||||||
|
transformChildren,
|
||||||
|
transformElement,
|
||||||
|
transformVText,
|
||||||
|
} from '../../src'
|
||||||
import { makeCompile } from './_utils'
|
import { makeCompile } from './_utils'
|
||||||
|
|
||||||
const compileWithVText = makeCompile({
|
const compileWithVText = makeCompile({
|
||||||
nodeTransforms: [transformElement],
|
nodeTransforms: [transformElement, transformChildren],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
text: transformVText,
|
text: transformVText,
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
transform,
|
transform,
|
||||||
} from './transform'
|
} from './transform'
|
||||||
import { type VaporCodegenResult, generate } from './generate'
|
import { type VaporCodegenResult, generate } from './generate'
|
||||||
|
import { transformChildren } from './transforms/transformChildren'
|
||||||
import { transformOnce } from './transforms/vOnce'
|
import { transformOnce } from './transforms/vOnce'
|
||||||
import { transformElement } from './transforms/transformElement'
|
import { transformElement } from './transforms/transformElement'
|
||||||
import { transformVHtml } from './transforms/vHtml'
|
import { transformVHtml } from './transforms/vHtml'
|
||||||
|
@ -26,6 +27,7 @@ import type { HackOptions } from './ir'
|
||||||
import { transformVModel } from './transforms/vModel'
|
import { transformVModel } from './transforms/vModel'
|
||||||
import { transformVIf } from './transforms/vIf'
|
import { transformVIf } from './transforms/vIf'
|
||||||
import { transformVFor } from './transforms/vFor'
|
import { transformVFor } from './transforms/vFor'
|
||||||
|
import { transformComment } from './transforms/transformComment'
|
||||||
|
|
||||||
export { wrapTemplate } from './transforms/utils'
|
export { wrapTemplate } from './transforms/utils'
|
||||||
|
|
||||||
|
@ -105,6 +107,8 @@ export function getBaseTransformPreset(
|
||||||
transformVFor,
|
transformVFor,
|
||||||
transformText,
|
transformText,
|
||||||
transformElement,
|
transformElement,
|
||||||
|
transformComment,
|
||||||
|
transformChildren,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
bind: transformVBind,
|
bind: transformVBind,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
import type { IREffect, RootIRNode, VaporHelper } from './ir'
|
import type { IREffect, RootIRNode, VaporHelper } from './ir'
|
||||||
import { SourceMapGenerator } from 'source-map-js'
|
import { SourceMapGenerator } from 'source-map-js'
|
||||||
import { extend, remove } from '@vue/shared'
|
import { extend, remove } from '@vue/shared'
|
||||||
import { genBlockFunctionContent } from './generators/block'
|
import { genBlockContent } from './generators/block'
|
||||||
import { genTemplates } from './generators/template'
|
import { genTemplates } from './generators/template'
|
||||||
import {
|
import {
|
||||||
type CodeFragment,
|
type CodeFragment,
|
||||||
|
@ -118,7 +118,7 @@ export function generate(
|
||||||
}
|
}
|
||||||
|
|
||||||
push(INDENT_START)
|
push(INDENT_START)
|
||||||
push(...genBlockFunctionContent(ir.block, context))
|
push(...genBlockContent(ir.block, context))
|
||||||
push(INDENT_END, NEWLINE)
|
push(INDENT_END, NEWLINE)
|
||||||
|
|
||||||
if (isSetupInlined) {
|
if (isSetupInlined) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { genEffects, genOperations } from './operation'
|
||||||
import { genChildren } from './template'
|
import { genChildren } from './template'
|
||||||
import { genMulti } from './utils'
|
import { genMulti } from './utils'
|
||||||
|
|
||||||
export function genBlockFunction(
|
export function genBlock(
|
||||||
oper: BlockIRNode,
|
oper: BlockIRNode,
|
||||||
context: CodegenContext,
|
context: CodegenContext,
|
||||||
args: CodeFragment[] = [],
|
args: CodeFragment[] = [],
|
||||||
|
@ -23,21 +23,23 @@ export function genBlockFunction(
|
||||||
...args,
|
...args,
|
||||||
') => {',
|
') => {',
|
||||||
INDENT_START,
|
INDENT_START,
|
||||||
...genBlockFunctionContent(oper, context, customReturns),
|
...genBlockContent(oper, context, customReturns),
|
||||||
INDENT_END,
|
INDENT_END,
|
||||||
NEWLINE,
|
NEWLINE,
|
||||||
'}',
|
'}',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genBlockFunctionContent(
|
export function genBlockContent(
|
||||||
{ dynamic, effect, operation, returns }: BlockIRNode,
|
{ dynamic, effect, operation, returns }: BlockIRNode,
|
||||||
context: CodegenContext,
|
context: CodegenContext,
|
||||||
customReturns?: (returns: CodeFragment[]) => CodeFragment[],
|
customReturns?: (returns: CodeFragment[]) => CodeFragment[],
|
||||||
): CodeFragment[] {
|
): CodeFragment[] {
|
||||||
const [frag, push] = buildCodeFragment()
|
const [frag, push] = buildCodeFragment()
|
||||||
|
|
||||||
push(...genChildren(dynamic, context, dynamic.id!))
|
for (const child of dynamic.children) {
|
||||||
|
push(...genChildren(child, context, child.id!))
|
||||||
|
}
|
||||||
|
|
||||||
const directiveOps = operation.filter(
|
const directiveOps = operation.filter(
|
||||||
(oper): oper is WithDirectiveIRNode =>
|
(oper): oper is WithDirectiveIRNode =>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { NewlineType } from '@vue/compiler-dom'
|
import { NewlineType } from '@vue/compiler-dom'
|
||||||
import { genBlockFunction } from './block'
|
import { genBlock } from './block'
|
||||||
import { genExpression } from './expression'
|
import { genExpression } from './expression'
|
||||||
import type { CodegenContext } from '../generate'
|
import type { CodegenContext } from '../generate'
|
||||||
import type { ForIRNode, IREffect } from '../ir'
|
import type { ForIRNode, IREffect } from '../ir'
|
||||||
|
@ -38,7 +38,7 @@ export function genFor(
|
||||||
]
|
]
|
||||||
|
|
||||||
const blockFn = context.withId(
|
const blockFn = context.withId(
|
||||||
() => genBlockFunction(render, context, ['_block'], blockReturns),
|
() => genBlock(render, context, ['_block'], blockReturns),
|
||||||
idMap,
|
idMap,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { CodegenContext } from '../generate'
|
import type { CodegenContext } from '../generate'
|
||||||
import { IRNodeTypes, type IfIRNode } from '../ir'
|
import { IRNodeTypes, type IfIRNode } from '../ir'
|
||||||
import { genBlockFunction } from './block'
|
import { genBlock } from './block'
|
||||||
import { genExpression } from './expression'
|
import { genExpression } from './expression'
|
||||||
import { type CodeFragment, NEWLINE, buildCodeFragment, genCall } from './utils'
|
import { type CodeFragment, NEWLINE, buildCodeFragment, genCall } from './utils'
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ export function genIf(
|
||||||
')',
|
')',
|
||||||
]
|
]
|
||||||
|
|
||||||
let positiveArg = genBlockFunction(positive, context)
|
let positiveArg = genBlock(positive, context)
|
||||||
let negativeArg: false | CodeFragment[] = false
|
let negativeArg: false | CodeFragment[] = false
|
||||||
|
|
||||||
if (negative) {
|
if (negative) {
|
||||||
if (negative.type === IRNodeTypes.BLOCK) {
|
if (negative.type === IRNodeTypes.BLOCK) {
|
||||||
negativeArg = genBlockFunction(negative, context)
|
negativeArg = genBlock(negative, context)
|
||||||
} else {
|
} else {
|
||||||
negativeArg = ['() => ', ...genIf(negative!, context, true)]
|
negativeArg = ['() => ', ...genIf(negative!, context, true)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ export function genChildren(
|
||||||
offset--
|
offset--
|
||||||
}
|
}
|
||||||
|
|
||||||
const elementIndex = Number(index) + offset
|
|
||||||
const id =
|
const id =
|
||||||
child.flags & DynamicFlag.REFERENCED
|
child.flags & DynamicFlag.REFERENCED
|
||||||
? child.flags & DynamicFlag.INSERT
|
? child.flags & DynamicFlag.INSERT
|
||||||
|
@ -42,6 +41,7 @@ export function genChildren(
|
||||||
: child.id
|
: child.id
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
|
const elementIndex = Number(index) + offset
|
||||||
const newPaths = [...paths, elementIndex]
|
const newPaths = [...paths, elementIndex]
|
||||||
|
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ export {
|
||||||
export * from './ir'
|
export * from './ir'
|
||||||
export * from './errors'
|
export * from './errors'
|
||||||
export { transformElement } from './transforms/transformElement'
|
export { transformElement } from './transforms/transformElement'
|
||||||
|
export { transformChildren } from './transforms/transformChildren'
|
||||||
export { transformText } from './transforms/transformText'
|
export { transformText } from './transforms/transformText'
|
||||||
export { transformVBind } from './transforms/vBind'
|
export { transformVBind } from './transforms/vBind'
|
||||||
export { transformVHtml } from './transforms/vHtml'
|
export { transformVHtml } from './transforms/vHtml'
|
||||||
|
@ -20,3 +21,4 @@ export { transformVText } from './transforms/vText'
|
||||||
export { transformVIf } from './transforms/vIf'
|
export { transformVIf } from './transforms/vIf'
|
||||||
export { transformVFor } from './transforms/vFor'
|
export { transformVFor } from './transforms/vFor'
|
||||||
export { transformVModel } from './transforms/vModel'
|
export { transformVModel } from './transforms/vModel'
|
||||||
|
export { transformComment } from './transforms/transformComment'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
type AllNode,
|
type AllNode,
|
||||||
type TransformOptions as BaseTransformOptions,
|
type TransformOptions as BaseTransformOptions,
|
||||||
|
type CommentNode,
|
||||||
type CompilerCompatOptions,
|
type CompilerCompatOptions,
|
||||||
type ElementNode,
|
type ElementNode,
|
||||||
ElementTypes,
|
ElementTypes,
|
||||||
|
@ -68,6 +69,8 @@ export interface TransformContext<T extends AllNode = AllNode> {
|
||||||
childrenTemplate: (string | null)[]
|
childrenTemplate: (string | null)[]
|
||||||
dynamic: IRDynamicInfo
|
dynamic: IRDynamicInfo
|
||||||
|
|
||||||
|
comment: CommentNode[]
|
||||||
|
|
||||||
inVOnce: boolean
|
inVOnce: boolean
|
||||||
|
|
||||||
enterBlock(ir: TransformContext['block']): () => void
|
enterBlock(ir: TransformContext['block']): () => void
|
||||||
|
@ -136,6 +139,7 @@ function createRootContext(
|
||||||
options: extend({}, defaultOptions, options),
|
options: extend({}, defaultOptions, options),
|
||||||
dynamic: root.block.dynamic,
|
dynamic: root.block.dynamic,
|
||||||
inVOnce: false,
|
inVOnce: false,
|
||||||
|
comment: [],
|
||||||
|
|
||||||
increaseId: () => globalId++,
|
increaseId: () => globalId++,
|
||||||
reference() {
|
reference() {
|
||||||
|
@ -172,7 +176,6 @@ function createRootContext(
|
||||||
template: '',
|
template: '',
|
||||||
childrenTemplate: [],
|
childrenTemplate: [],
|
||||||
registerTemplate() {
|
registerTemplate() {
|
||||||
this.template += this.childrenTemplate.filter(Boolean).join('')
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -196,22 +199,6 @@ function createRootContext(
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
function createContext<T extends TemplateChildNode>(
|
|
||||||
node: T,
|
|
||||||
parent: TransformContext<RootNode | ElementNode>,
|
|
||||||
index: number,
|
|
||||||
): TransformContext<T> {
|
|
||||||
return extend({}, parent, {
|
|
||||||
node,
|
|
||||||
parent,
|
|
||||||
index,
|
|
||||||
|
|
||||||
template: '',
|
|
||||||
childrenTemplate: [],
|
|
||||||
dynamic: genDefaultDynamic(),
|
|
||||||
} satisfies Partial<TransformContext<T>>) satisfies TransformContext<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
// AST -> IR
|
// AST -> IR
|
||||||
export function transform(
|
export function transform(
|
||||||
root: RootNode,
|
root: RootNode,
|
||||||
|
@ -241,7 +228,7 @@ export function transform(
|
||||||
return ir
|
return ir
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformNode(
|
export function transformNode(
|
||||||
context: TransformContext<RootNode | TemplateChildNode>,
|
context: TransformContext<RootNode | TemplateChildNode>,
|
||||||
) {
|
) {
|
||||||
let { node } = context
|
let { node } = context
|
||||||
|
@ -267,18 +254,6 @@ function transformNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (node.type) {
|
|
||||||
case NodeTypes.ROOT:
|
|
||||||
case NodeTypes.ELEMENT: {
|
|
||||||
transformChildren(context as TransformContext<RootNode | ElementNode>)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case NodeTypes.COMMENT: {
|
|
||||||
context.template += `<!--${node.content}-->`
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// exit transforms
|
// exit transforms
|
||||||
context.node = node
|
context.node = node
|
||||||
let i = exitFns.length
|
let i = exitFns.length
|
||||||
|
@ -291,88 +266,6 @@ function transformNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformChildren(context: TransformContext<RootNode | ElementNode>) {
|
|
||||||
const { children } = context.node
|
|
||||||
|
|
||||||
let referencedCount = 0
|
|
||||||
for (const [i, child] of children.entries()) {
|
|
||||||
const childContext = createContext(child, context, i)
|
|
||||||
transformNode(childContext)
|
|
||||||
context.childrenTemplate.push(childContext.template)
|
|
||||||
context.dynamic.children[i] = childContext.dynamic
|
|
||||||
if (childContext.dynamic.flags & DynamicFlag.REFERENCED) {
|
|
||||||
referencedCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (referencedCount > 1) {
|
|
||||||
context.reference()
|
|
||||||
}
|
|
||||||
|
|
||||||
processDynamicChildren(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
function processDynamicChildren(
|
|
||||||
context: TransformContext<RootNode | ElementNode>,
|
|
||||||
) {
|
|
||||||
let prevDynamics: IRDynamicInfo[] = []
|
|
||||||
let hasStaticTemplate = false
|
|
||||||
const children = context.dynamic.children
|
|
||||||
|
|
||||||
const isFragment = context.block.node === context.node
|
|
||||||
const allNonTemplate = children.every(
|
|
||||||
child => child.flags & DynamicFlag.NON_TEMPLATE,
|
|
||||||
)
|
|
||||||
// all non-template: don't gen fragment but return array directly
|
|
||||||
if (isFragment && allNonTemplate) {
|
|
||||||
context.block.returns = children
|
|
||||||
.filter(child => child.flags & DynamicFlag.INSERT)
|
|
||||||
.map(child => child.id!)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// mixed: insert with anchor
|
|
||||||
context.block.returns = [context.dynamic.id!]
|
|
||||||
for (const [index, child] of children.entries()) {
|
|
||||||
if (child.flags & DynamicFlag.INSERT) {
|
|
||||||
prevDynamics.push(child)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(child.flags & DynamicFlag.NON_TEMPLATE)) {
|
|
||||||
if (prevDynamics.length) {
|
|
||||||
if (hasStaticTemplate) {
|
|
||||||
context.childrenTemplate[index - prevDynamics.length] = `<!>`
|
|
||||||
|
|
||||||
prevDynamics[0].flags -= DynamicFlag.NON_TEMPLATE
|
|
||||||
const anchor = (prevDynamics[0].anchor = context.increaseId())
|
|
||||||
|
|
||||||
context.registerOperation({
|
|
||||||
type: IRNodeTypes.INSERT_NODE,
|
|
||||||
element: prevDynamics.map(child => child.id!),
|
|
||||||
parent: context.reference(),
|
|
||||||
anchor,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
context.registerOperation({
|
|
||||||
type: IRNodeTypes.PREPEND_NODE,
|
|
||||||
elements: prevDynamics.map(child => child.id!),
|
|
||||||
parent: context.reference(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
prevDynamics = []
|
|
||||||
}
|
|
||||||
hasStaticTemplate = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevDynamics.length) {
|
|
||||||
context.registerOperation({
|
|
||||||
type: IRNodeTypes.APPEND_NODE,
|
|
||||||
elements: prevDynamics.map(child => child.id!),
|
|
||||||
parent: context.reference(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createStructuralDirectiveTransform(
|
export function createStructuralDirectiveTransform(
|
||||||
name: string | string[],
|
name: string | string[],
|
||||||
fn: StructuralDirectiveTransform,
|
fn: StructuralDirectiveTransform,
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
import {
|
||||||
|
type ElementNode,
|
||||||
|
ElementTypes,
|
||||||
|
NodeTypes,
|
||||||
|
type RootNode,
|
||||||
|
type TemplateChildNode,
|
||||||
|
} from '@vue/compiler-dom'
|
||||||
|
import {
|
||||||
|
type NodeTransform,
|
||||||
|
type TransformContext,
|
||||||
|
transformNode,
|
||||||
|
} from '../transform'
|
||||||
|
import { DynamicFlag, type IRDynamicInfo, IRNodeTypes } from '../ir'
|
||||||
|
import { extend } from '@vue/shared'
|
||||||
|
import { genDefaultDynamic } from './utils'
|
||||||
|
|
||||||
|
export const transformChildren: NodeTransform = (node, context) => {
|
||||||
|
const isFragment =
|
||||||
|
node.type === NodeTypes.ROOT ||
|
||||||
|
(node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.TEMPLATE)
|
||||||
|
|
||||||
|
if (!isFragment && node.type !== NodeTypes.ELEMENT) return
|
||||||
|
|
||||||
|
let referencedCount = 0
|
||||||
|
for (const [i, child] of node.children.entries()) {
|
||||||
|
const childContext = createContext(
|
||||||
|
child,
|
||||||
|
context as TransformContext<RootNode | ElementNode>,
|
||||||
|
i,
|
||||||
|
)
|
||||||
|
transformNode(childContext)
|
||||||
|
|
||||||
|
if (isFragment) {
|
||||||
|
childContext.reference()
|
||||||
|
childContext.registerTemplate()
|
||||||
|
|
||||||
|
if (
|
||||||
|
!(childContext.dynamic.flags & DynamicFlag.NON_TEMPLATE) ||
|
||||||
|
childContext.dynamic.flags & DynamicFlag.INSERT
|
||||||
|
) {
|
||||||
|
context.block.returns.push(childContext.dynamic.id!)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.childrenTemplate.push(childContext.template)
|
||||||
|
if (childContext.dynamic.flags & DynamicFlag.REFERENCED) {
|
||||||
|
referencedCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.dynamic.children[i] = childContext.dynamic
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isFragment) {
|
||||||
|
if (referencedCount > 1) {
|
||||||
|
context.reference()
|
||||||
|
}
|
||||||
|
processDynamicChildren(context as TransformContext<ElementNode>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processDynamicChildren(context: TransformContext<ElementNode>) {
|
||||||
|
let prevDynamics: IRDynamicInfo[] = []
|
||||||
|
let hasStaticTemplate = false
|
||||||
|
const children = context.dynamic.children
|
||||||
|
|
||||||
|
for (const [index, child] of children.entries()) {
|
||||||
|
if (child.flags & DynamicFlag.INSERT) {
|
||||||
|
prevDynamics.push(child)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(child.flags & DynamicFlag.NON_TEMPLATE)) {
|
||||||
|
if (prevDynamics.length) {
|
||||||
|
if (hasStaticTemplate) {
|
||||||
|
context.childrenTemplate[index - prevDynamics.length] = `<!>`
|
||||||
|
|
||||||
|
prevDynamics[0].flags -= DynamicFlag.NON_TEMPLATE
|
||||||
|
const anchor = (prevDynamics[0].anchor = context.increaseId())
|
||||||
|
|
||||||
|
context.registerOperation({
|
||||||
|
type: IRNodeTypes.INSERT_NODE,
|
||||||
|
element: prevDynamics.map(child => child.id!),
|
||||||
|
parent: context.reference(),
|
||||||
|
anchor,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
context.registerOperation({
|
||||||
|
type: IRNodeTypes.PREPEND_NODE,
|
||||||
|
elements: prevDynamics.map(child => child.id!),
|
||||||
|
parent: context.reference(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
prevDynamics = []
|
||||||
|
}
|
||||||
|
hasStaticTemplate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevDynamics.length) {
|
||||||
|
context.registerOperation({
|
||||||
|
type: IRNodeTypes.APPEND_NODE,
|
||||||
|
elements: prevDynamics.map(child => child.id!),
|
||||||
|
parent: context.reference(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createContext<T extends TemplateChildNode>(
|
||||||
|
node: T,
|
||||||
|
parent: TransformContext<RootNode | ElementNode>,
|
||||||
|
index: number,
|
||||||
|
): TransformContext<T> {
|
||||||
|
return extend({}, parent, {
|
||||||
|
node,
|
||||||
|
parent,
|
||||||
|
index,
|
||||||
|
|
||||||
|
template: '',
|
||||||
|
childrenTemplate: [],
|
||||||
|
dynamic: genDefaultDynamic(),
|
||||||
|
} satisfies Partial<TransformContext<T>>) satisfies TransformContext<T>
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
import {
|
||||||
|
type CommentNode,
|
||||||
|
NodeTypes,
|
||||||
|
type TemplateChildNode,
|
||||||
|
} from '@vue/compiler-dom'
|
||||||
|
import type { NodeTransform, TransformContext } from '../transform'
|
||||||
|
import { DynamicFlag } from '../ir'
|
||||||
|
|
||||||
|
export const transformComment: NodeTransform = (node, context) => {
|
||||||
|
if (node.type !== NodeTypes.COMMENT) return
|
||||||
|
|
||||||
|
if (getSiblingIf(context as TransformContext<CommentNode>)) {
|
||||||
|
context.comment.push(node)
|
||||||
|
context.dynamic.flags |= DynamicFlag.NON_TEMPLATE
|
||||||
|
} else {
|
||||||
|
context.template += `<!--${node.content}-->`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSiblingIf(
|
||||||
|
context: TransformContext<TemplateChildNode>,
|
||||||
|
reverse?: boolean,
|
||||||
|
) {
|
||||||
|
const parent = context.parent
|
||||||
|
if (!parent) return
|
||||||
|
|
||||||
|
const siblings = parent.node.children
|
||||||
|
let sibling: TemplateChildNode | undefined
|
||||||
|
let i = siblings.indexOf(context.node)
|
||||||
|
while (reverse ? --i >= 0 : ++i < siblings.length) {
|
||||||
|
sibling = siblings[i]
|
||||||
|
if (!isCommentLike(sibling)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
sibling &&
|
||||||
|
sibling.type === NodeTypes.ELEMENT &&
|
||||||
|
sibling.props.some(
|
||||||
|
({ type, name }) =>
|
||||||
|
type === NodeTypes.DIRECTIVE &&
|
||||||
|
['else-if', reverse ? 'if' : 'else'].includes(name),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return sibling
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCommentLike(node: TemplateChildNode) {
|
||||||
|
return (
|
||||||
|
node.type === NodeTypes.COMMENT ||
|
||||||
|
(node.type === NodeTypes.TEXT && !node.content.trim().length)
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
import {
|
import {
|
||||||
type ElementNode,
|
type ElementNode,
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
NodeTypes,
|
|
||||||
type TemplateChildNode,
|
|
||||||
createCompilerError,
|
createCompilerError,
|
||||||
createSimpleExpression,
|
createSimpleExpression,
|
||||||
} from '@vue/compiler-dom'
|
} from '@vue/compiler-dom'
|
||||||
|
@ -15,11 +13,11 @@ import {
|
||||||
DynamicFlag,
|
DynamicFlag,
|
||||||
type IRDynamicInfo,
|
type IRDynamicInfo,
|
||||||
IRNodeTypes,
|
IRNodeTypes,
|
||||||
type OperationNode,
|
|
||||||
type VaporDirectiveNode,
|
type VaporDirectiveNode,
|
||||||
} from '../ir'
|
} from '../ir'
|
||||||
import { extend } from '@vue/shared'
|
import { extend } from '@vue/shared'
|
||||||
import { genDefaultDynamic, wrapTemplate } from './utils'
|
import { genDefaultDynamic, wrapTemplate } from './utils'
|
||||||
|
import { getSiblingIf } from './transformComment'
|
||||||
|
|
||||||
export const transformVIf = createStructuralDirectiveTransform(
|
export const transformVIf = createStructuralDirectiveTransform(
|
||||||
['if', 'else', 'else-if'],
|
['if', 'else', 'else-if'],
|
||||||
|
@ -56,43 +54,16 @@ export function processIf(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check the adjacent v-if
|
// check the adjacent v-if
|
||||||
const parent = context.parent!
|
const siblingIf = getSiblingIf(context, true)
|
||||||
const siblings = parent.node.children
|
|
||||||
const templates = parent.childrenTemplate
|
|
||||||
const siblingsDynamic = parent.dynamic.children
|
|
||||||
|
|
||||||
const comments = []
|
|
||||||
let sibling: TemplateChildNode | undefined
|
|
||||||
let i = siblings.indexOf(node)
|
|
||||||
while (i-- >= -1) {
|
|
||||||
sibling = siblings[i]
|
|
||||||
|
|
||||||
if (
|
|
||||||
sibling &&
|
|
||||||
(sibling.type === NodeTypes.COMMENT ||
|
|
||||||
(sibling.type === NodeTypes.TEXT && !sibling.content.trim().length))
|
|
||||||
) {
|
|
||||||
if (__DEV__ && sibling.type === NodeTypes.COMMENT)
|
|
||||||
comments.unshift(sibling)
|
|
||||||
siblingsDynamic[i].flags |= DynamicFlag.NON_TEMPLATE
|
|
||||||
templates[i] = null
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { operation } = context.block
|
const { operation } = context.block
|
||||||
let lastIfNode: OperationNode
|
let lastIfNode = operation[operation.length - 1]
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// check if v-if is the sibling node
|
// check if v-if is the sibling node
|
||||||
!sibling ||
|
!siblingIf ||
|
||||||
sibling.type !== NodeTypes.ELEMENT ||
|
// check if IfNode is the last operation and get the root IfNode
|
||||||
!sibling.props.some(
|
!lastIfNode ||
|
||||||
({ type, name }) =>
|
|
||||||
type === NodeTypes.DIRECTIVE && ['if', 'else-if'].includes(name),
|
|
||||||
) ||
|
|
||||||
// check if IFNode is the last operation and get the root IFNode
|
|
||||||
!(lastIfNode = operation[operation.length - 1]) ||
|
|
||||||
lastIfNode.type !== IRNodeTypes.IF
|
lastIfNode.type !== IRNodeTypes.IF
|
||||||
) {
|
) {
|
||||||
context.options.onError(
|
context.options.onError(
|
||||||
|
@ -113,12 +84,13 @@ export function processIf(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO ignore comments if the v-if is direct child of <transition> (PR #3622)
|
// TODO ignore comments if the v-if is direct child of <transition> (PR #3622)
|
||||||
if (__DEV__ && comments.length) {
|
if (__DEV__ && context.root.comment.length) {
|
||||||
node = wrapTemplate(node, ['else-if', 'else'])
|
node = wrapTemplate(node, ['else-if', 'else'])
|
||||||
context.node = node = extend({}, node, {
|
context.node = node = extend({}, node, {
|
||||||
children: [...comments, ...node.children],
|
children: [...context.comment, ...node.children],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
context.root.comment = []
|
||||||
|
|
||||||
const [branch, onExit] = createIfBranch(node, context)
|
const [branch, onExit] = createIfBranch(node, context)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import { ref, setText, template, unmountComponent, watchEffect } from '../src'
|
||||||
children,
|
|
||||||
ref,
|
|
||||||
setText,
|
|
||||||
template,
|
|
||||||
unmountComponent,
|
|
||||||
watchEffect,
|
|
||||||
} from '../src'
|
|
||||||
import { describe, expect } from 'vitest'
|
import { describe, expect } from 'vitest'
|
||||||
import { makeRender } from './_utils'
|
import { makeRender } from './_utils'
|
||||||
|
|
||||||
|
@ -17,9 +10,8 @@ describe('component', () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const t0 = template('<div></div>')
|
const t0 = template('<div></div>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setText(n1, count.value)
|
setText(n0, count.value)
|
||||||
})
|
})
|
||||||
return n0
|
return n0
|
||||||
}).render()
|
}).render()
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
import { setCurrentInstance } from '../src/component'
|
import { setCurrentInstance } from '../src/component'
|
||||||
import {
|
import {
|
||||||
children,
|
|
||||||
defineComponent,
|
defineComponent,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
@ -290,11 +289,10 @@ describe('component props (vapor)', () => {
|
||||||
props: ['foo'],
|
props: ['foo'],
|
||||||
render() {
|
render() {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const t0 = template('<div><!></div>')
|
const t0 = template('<div></div>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setText(n1, instance.props.foo)
|
setText(n0, instance.props.foo)
|
||||||
})
|
})
|
||||||
return n0
|
return n0
|
||||||
},
|
},
|
||||||
|
@ -307,7 +305,7 @@ describe('component props (vapor)', () => {
|
||||||
return { foo, id }
|
return { foo, id }
|
||||||
},
|
},
|
||||||
render(_ctx: Record<string, any>) {
|
render(_ctx: Record<string, any>) {
|
||||||
const t0 = template('')
|
const t0 = template('<div>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
renderChild(
|
renderChild(
|
||||||
{
|
{
|
||||||
|
@ -318,19 +316,19 @@ describe('component props (vapor)', () => {
|
||||||
return _ctx.id
|
return _ctx.id
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
n0 as any, // TODO: type
|
n0 as HTMLDivElement,
|
||||||
)
|
)
|
||||||
return n0
|
return n0
|
||||||
},
|
},
|
||||||
}).render()
|
}).render()
|
||||||
const reset = setCurrentInstance(instance)
|
const reset = setCurrentInstance(instance)
|
||||||
// expect(host.innerHTML).toBe('<div id="a">1</div>') // TODO: Fallthrough Attributes
|
// expect(host.innerHTML).toBe('<div id="a">1</div>') // TODO: Fallthrough Attributes
|
||||||
expect(host.innerHTML).toBe('<div>1</div>')
|
expect(host.innerHTML).toBe('<div><div>1</div></div>')
|
||||||
|
|
||||||
foo.value++
|
foo.value++
|
||||||
await nextTick()
|
await nextTick()
|
||||||
// expect(host.innerHTML).toBe('<div id="a">2</div>') // TODO: Fallthrough Attributes
|
// expect(host.innerHTML).toBe('<div id="a">2</div>') // TODO: Fallthrough Attributes
|
||||||
expect(host.innerHTML).toBe('<div>2</div>')
|
expect(host.innerHTML).toBe('<div><div>2</div></div>')
|
||||||
|
|
||||||
// id.value = 'b'
|
// id.value = 'b'
|
||||||
// await nextTick()
|
// await nextTick()
|
||||||
|
@ -468,9 +466,8 @@ describe('component props (vapor)', () => {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const t0 = template('<div></div>')
|
const t0 = template('<div></div>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setText(n1, instance.props.foo)
|
setText(n0, instance.props.foo)
|
||||||
})
|
})
|
||||||
return n0
|
return n0
|
||||||
},
|
},
|
||||||
|
@ -540,10 +537,9 @@ describe('component props (vapor)', () => {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const t0 = template('<div></div>')
|
const t0 = template('<div></div>')
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setText(
|
setText(
|
||||||
n1,
|
n0,
|
||||||
JSON.stringify(instance.attrs) + Object.keys(instance.attrs),
|
JSON.stringify(instance.attrs) + Object.keys(instance.attrs),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import {
|
||||||
append,
|
|
||||||
children,
|
|
||||||
createIf,
|
createIf,
|
||||||
insert,
|
insert,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
@ -33,7 +31,6 @@ describe('createIf', () => {
|
||||||
|
|
||||||
const { host } = define(() => {
|
const { host } = define(() => {
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
|
||||||
|
|
||||||
insert(
|
insert(
|
||||||
createIf(
|
createIf(
|
||||||
|
@ -41,10 +38,8 @@ describe('createIf', () => {
|
||||||
// v-if
|
// v-if
|
||||||
(spyIfFn ||= vi.fn(() => {
|
(spyIfFn ||= vi.fn(() => {
|
||||||
const n2 = t1()
|
const n2 = t1()
|
||||||
const n3 = children(n2, 0)
|
|
||||||
|
|
||||||
renderEffect(() => {
|
renderEffect(() => {
|
||||||
setText(n3, count.value)
|
setText(n2, count.value)
|
||||||
})
|
})
|
||||||
return n2
|
return n2
|
||||||
})),
|
})),
|
||||||
|
@ -54,7 +49,7 @@ describe('createIf', () => {
|
||||||
return n4
|
return n4
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
n1 as any as ParentNode,
|
n0 as any as ParentNode,
|
||||||
)
|
)
|
||||||
return n0
|
return n0
|
||||||
}).render()
|
}).render()
|
||||||
|
@ -105,11 +100,10 @@ describe('createIf', () => {
|
||||||
return n4
|
return n4
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
append(n2, n3)
|
return [n2, n3]
|
||||||
return n2
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return [n1]
|
return n1
|
||||||
}).render()
|
}).render()
|
||||||
|
|
||||||
expect(host.innerHTML).toBe('Hello Vapor<!--if--><!--if-->')
|
expect(host.innerHTML).toBe('Hello Vapor<!--if--><!--if-->')
|
||||||
|
|
|
@ -4,11 +4,10 @@ describe('api: template', () => {
|
||||||
test('create element', () => {
|
test('create element', () => {
|
||||||
const t = template('<div>')
|
const t = template('<div>')
|
||||||
const root = t()
|
const root = t()
|
||||||
expect(root).toBeInstanceOf(Array)
|
expect(root).toBeInstanceOf(HTMLDivElement)
|
||||||
expect(root[0]).toBeInstanceOf(HTMLDivElement)
|
|
||||||
|
|
||||||
const root2 = t()
|
const root2 = t()
|
||||||
expect(root2).toBeInstanceOf(Array)
|
expect(root2).toBeInstanceOf(HTMLDivElement)
|
||||||
expect(root2).not.toBe(root)
|
expect(root2).not.toBe(root)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,9 @@ const createDemo = (defaultValue: boolean) =>
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
visible.value = !visible.value
|
visible.value = !visible.value
|
||||||
}
|
}
|
||||||
const t0 = template('<button>toggle</button><h1>hello world</h1>')
|
const t0 = template(
|
||||||
|
'<div><button>toggle</button><h1>hello world</h1></div>',
|
||||||
|
)
|
||||||
const n0 = t0()
|
const n0 = t0()
|
||||||
const n1 = children(n0, 0)
|
const n1 = children(n0, 0)
|
||||||
const n2 = children(n0, 1)
|
const n2 = children(n0, 1)
|
||||||
|
@ -23,11 +25,13 @@ describe('directive: v-show', () => {
|
||||||
test('basic', async () => {
|
test('basic', async () => {
|
||||||
const { host } = createDemo(true).render()
|
const { host } = createDemo(true).render()
|
||||||
const btn = host.querySelector('button')
|
const btn = host.querySelector('button')
|
||||||
expect(host.innerHTML).toBe('<button>toggle</button><h1>hello world</h1>')
|
expect(host.innerHTML).toBe(
|
||||||
|
'<div><button>toggle</button><h1>hello world</h1></div>',
|
||||||
|
)
|
||||||
btn?.click()
|
btn?.click()
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect(host.innerHTML).toBe(
|
expect(host.innerHTML).toBe(
|
||||||
'<button>toggle</button><h1 style="display: none;">hello world</h1>',
|
'<div><button>toggle</button><h1 style="display: none;">hello world</h1></div>',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
test('should hide content when default value is false', async () => {
|
test('should hide content when default value is false', async () => {
|
||||||
|
|
|
@ -1,30 +1,15 @@
|
||||||
import { isArray } from '@vue/shared'
|
import { isArray } from '@vue/shared'
|
||||||
|
|
||||||
/*! #__NO_SIDE_EFFECTS__ */
|
/*! #__NO_SIDE_EFFECTS__ */
|
||||||
export function template(str: string): () => ChildNode[] {
|
export function template(html: string) {
|
||||||
let cached = false
|
let node: ChildNode
|
||||||
let node: DocumentFragment
|
const create = () => {
|
||||||
return () => {
|
// eslint-disable-next-line no-restricted-globals
|
||||||
if (!cached) {
|
const t = document.createElement('template')
|
||||||
cached = true
|
t.innerHTML = html
|
||||||
// eslint-disable-next-line no-restricted-globals
|
return t.content.firstChild!
|
||||||
const t = document.createElement('template')
|
|
||||||
t.innerHTML = str
|
|
||||||
// first render: insert the node directly.
|
|
||||||
// this removes it from the template fragment to avoid keeping two copies
|
|
||||||
// of the inserted tree in memory, even if the template is used only once.
|
|
||||||
return fragmentToNodes((node = t.content))
|
|
||||||
} else {
|
|
||||||
// repeated renders: clone from cache. This is more performant and
|
|
||||||
// efficient when dealing with big lists where the template is repeated
|
|
||||||
// many times.
|
|
||||||
return fragmentToNodes(node)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
return () => (node || (node = create())).cloneNode(true)
|
||||||
|
|
||||||
function fragmentToNodes(node: DocumentFragment): ChildNode[] {
|
|
||||||
return Array.from((node.cloneNode(true) as DocumentFragment).childNodes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! #__NO_SIDE_EFFECTS__ */
|
/*! #__NO_SIDE_EFFECTS__ */
|
||||||
|
|
Loading…
Reference in New Issue