test: update tests and snapshots for helper prefixing
This commit is contained in:
@@ -27,9 +27,9 @@ export function render() {
|
||||
const _ctx = this
|
||||
const _cache = _ctx.$cache
|
||||
return _cache[1] || (
|
||||
setBlockTracking(-1),
|
||||
_setBlockTracking(-1),
|
||||
_cache[1] = foo,
|
||||
setBlockTracking(1),
|
||||
_setBlockTracking(1),
|
||||
_cache[1]
|
||||
)
|
||||
}"
|
||||
@@ -126,7 +126,7 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: codegen function mode preamble w/ prefixIdentifiers: true 1`] = `
|
||||
"const { createVNode, resolveDirective } = Vue
|
||||
"const { createVNode: _createVNode, resolveDirective: _resolveDirective } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
@@ -165,8 +165,20 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: codegen module mode preamble 1`] = `
|
||||
"import { createVNode as _createVNode, resolveDirective as _resolveDirective } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return null
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: codegen module mode preamble w/ optimizeBindings: true 1`] = `
|
||||
"import { createVNode, resolveDirective } from \\"vue\\"
|
||||
|
||||
// Binding optimization for webpack code-split
|
||||
const _createVNode = createVNode, _resolveDirective = resolveDirective
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return null
|
||||
|
||||
@@ -26,21 +26,21 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: integration tests function mode w/ prefixIdentifiers: true 1`] = `
|
||||
"const { toDisplayString, createVNode, openBlock, createBlock, createCommentVNode, Fragment, renderList, createTextVNode } = Vue
|
||||
"const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment, renderList: _renderList, createTextVNode: _createTextVNode } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"div\\", {
|
||||
return (_openBlock(), _createBlock(\\"div\\", {
|
||||
id: \\"foo\\",
|
||||
class: _ctx.bar.baz
|
||||
}, [
|
||||
createTextVNode(toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
|
||||
(openBlock(), (_ctx.ok)
|
||||
? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
|
||||
: createBlock(Fragment, { key: 1 }, [\\"no\\"])),
|
||||
(openBlock(false), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
|
||||
return (openBlock(), createBlock(\\"div\\", null, [
|
||||
createVNode(\\"span\\", null, toDisplayString(value + index), 1 /* TEXT */)
|
||||
_createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
|
||||
(_openBlock(), (_ctx.ok)
|
||||
? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
|
||||
: _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
|
||||
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
|
||||
return (_openBlock(), _createBlock(\\"div\\", null, [
|
||||
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
|
||||
]))
|
||||
}), 256 /* UNKEYED_FRAGMENT */))
|
||||
], 2 /* CLASS */))
|
||||
@@ -48,21 +48,21 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: integration tests module mode 1`] = `
|
||||
"import { toDisplayString, createVNode, openBlock, createBlock, createCommentVNode, Fragment, renderList, createTextVNode } from \\"vue\\"
|
||||
"import { toDisplayString as _toDisplayString, createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, Fragment as _Fragment, renderList as _renderList, createTextVNode as _createTextVNode } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"div\\", {
|
||||
return (_openBlock(), _createBlock(\\"div\\", {
|
||||
id: \\"foo\\",
|
||||
class: _ctx.bar.baz
|
||||
}, [
|
||||
createTextVNode(toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
|
||||
(openBlock(), (_ctx.ok)
|
||||
? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
|
||||
: createBlock(Fragment, { key: 1 }, [\\"no\\"])),
|
||||
(openBlock(false), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
|
||||
return (openBlock(), createBlock(\\"div\\", null, [
|
||||
createVNode(\\"span\\", null, toDisplayString(value + index), 1 /* TEXT */)
|
||||
_createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
|
||||
(_openBlock(), (_ctx.ok)
|
||||
? _createBlock(\\"div\\", { key: 0 }, \\"yes\\")
|
||||
: _createBlock(_Fragment, { key: 1 }, [\\"no\\"])),
|
||||
(_openBlock(false), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
|
||||
return (_openBlock(), _createBlock(\\"div\\", null, [
|
||||
_createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
|
||||
]))
|
||||
}), 256 /* UNKEYED_FRAGMENT */))
|
||||
], 2 /* CLASS */))
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`scopeId compiler support should push scopeId for hoisted nodes 1`] = `
|
||||
"import { createVNode, createBlock, openBlock, withScopeId, pushScopeId, popScopeId } from \\"vue\\"
|
||||
const withId = withScopeId(\\"test\\")
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"
|
||||
const _withId = _withScopeId(\\"test\\")
|
||||
|
||||
pushScopeId(\\"test\\")
|
||||
const _hoisted_1 = createVNode(\\"div\\", null, \\"hello\\")
|
||||
const _hoisted_2 = createVNode(\\"div\\", null, \\"world\\")
|
||||
popScopeId()
|
||||
_pushScopeId(\\"test\\")
|
||||
const _hoisted_1 = _createVNode(\\"div\\", null, \\"hello\\")
|
||||
const _hoisted_2 = _createVNode(\\"div\\", null, \\"world\\")
|
||||
_popScopeId()
|
||||
|
||||
export const render = withId(function render() {
|
||||
export const render = _withId(function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"div\\", null, [
|
||||
return (_openBlock(), _createBlock(\\"div\\", null, [
|
||||
_hoisted_1,
|
||||
_hoisted_2
|
||||
]))
|
||||
@@ -19,16 +19,16 @@ export const render = withId(function render() {
|
||||
`;
|
||||
|
||||
exports[`scopeId compiler support should wrap default slot 1`] = `
|
||||
"import { createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||
const withId = withScopeId(\\"test\\")
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent, createBlock as _createBlock, openBlock as _openBlock, withScopeId as _withScopeId } from \\"vue\\"
|
||||
const _withId = _withScopeId(\\"test\\")
|
||||
|
||||
export const render = withId(function render() {
|
||||
export const render = _withId(function render() {
|
||||
const _ctx = this
|
||||
const _component_Child = resolveComponent(\\"Child\\")
|
||||
const _component_Child = _resolveComponent(\\"Child\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Child, null, {
|
||||
default: withId(() => [
|
||||
createVNode(\\"div\\")
|
||||
return (_openBlock(), _createBlock(_component_Child, null, {
|
||||
default: _withId(() => [
|
||||
_createVNode(\\"div\\")
|
||||
]),
|
||||
_compiled: true
|
||||
}))
|
||||
@@ -36,27 +36,27 @@ export const render = withId(function render() {
|
||||
`;
|
||||
|
||||
exports[`scopeId compiler support should wrap dynamic slots 1`] = `
|
||||
"import { createVNode, resolveComponent, renderList, createSlots, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||
const withId = withScopeId(\\"test\\")
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent, renderList as _renderList, createSlots as _createSlots, createBlock as _createBlock, openBlock as _openBlock, withScopeId as _withScopeId } from \\"vue\\"
|
||||
const _withId = _withScopeId(\\"test\\")
|
||||
|
||||
export const render = withId(function render() {
|
||||
export const render = _withId(function render() {
|
||||
const _ctx = this
|
||||
const _component_Child = resolveComponent(\\"Child\\")
|
||||
const _component_Child = _resolveComponent(\\"Child\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Child, null, createSlots({ _compiled: true }, [
|
||||
return (_openBlock(), _createBlock(_component_Child, null, _createSlots({ _compiled: true }, [
|
||||
(_ctx.ok)
|
||||
? {
|
||||
name: \\"foo\\",
|
||||
fn: withId(() => [
|
||||
createVNode(\\"div\\")
|
||||
fn: _withId(() => [
|
||||
_createVNode(\\"div\\")
|
||||
])
|
||||
}
|
||||
: undefined,
|
||||
renderList(_ctx.list, (i) => {
|
||||
_renderList(_ctx.list, (i) => {
|
||||
return {
|
||||
name: i,
|
||||
fn: withId(() => [
|
||||
createVNode(\\"div\\")
|
||||
fn: _withId(() => [
|
||||
_createVNode(\\"div\\")
|
||||
])
|
||||
}
|
||||
})
|
||||
@@ -65,19 +65,19 @@ export const render = withId(function render() {
|
||||
`;
|
||||
|
||||
exports[`scopeId compiler support should wrap named slots 1`] = `
|
||||
"import { toDisplayString, createTextVNode, createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||
const withId = withScopeId(\\"test\\")
|
||||
"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createVNode as _createVNode, resolveComponent as _resolveComponent, createBlock as _createBlock, openBlock as _openBlock, withScopeId as _withScopeId } from \\"vue\\"
|
||||
const _withId = _withScopeId(\\"test\\")
|
||||
|
||||
export const render = withId(function render() {
|
||||
export const render = _withId(function render() {
|
||||
const _ctx = this
|
||||
const _component_Child = resolveComponent(\\"Child\\")
|
||||
const _component_Child = _resolveComponent(\\"Child\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Child, null, {
|
||||
foo: withId(({ msg }) => [
|
||||
createTextVNode(toDisplayString(msg), 1 /* TEXT */)
|
||||
return (_openBlock(), _createBlock(_component_Child, null, {
|
||||
foo: _withId(({ msg }) => [
|
||||
_createTextVNode(_toDisplayString(msg), 1 /* TEXT */)
|
||||
]),
|
||||
bar: withId(() => [
|
||||
createVNode(\\"div\\")
|
||||
bar: _withId(() => [
|
||||
_createVNode(\\"div\\")
|
||||
]),
|
||||
_compiled: true
|
||||
}))
|
||||
@@ -85,11 +85,11 @@ export const render = withId(function render() {
|
||||
`;
|
||||
|
||||
exports[`scopeId compiler support should wrap render function 1`] = `
|
||||
"import { createVNode, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||
const withId = withScopeId(\\"test\\")
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock, withScopeId as _withScopeId } from \\"vue\\"
|
||||
const _withId = _withScopeId(\\"test\\")
|
||||
|
||||
export const render = withId(function render() {
|
||||
export const render = _withId(function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"div\\"))
|
||||
return (_openBlock(), _createBlock(\\"div\\"))
|
||||
})"
|
||||
`;
|
||||
|
||||
@@ -54,11 +54,33 @@ describe('compiler: codegen', () => {
|
||||
helpers: [CREATE_VNODE, RESOLVE_DIRECTIVE]
|
||||
})
|
||||
const { code } = generate(root, { mode: 'module' })
|
||||
expect(code).toMatch(
|
||||
`import { ${helperNameMap[CREATE_VNODE]} as _${
|
||||
helperNameMap[CREATE_VNODE]
|
||||
}, ${helperNameMap[RESOLVE_DIRECTIVE]} as _${
|
||||
helperNameMap[RESOLVE_DIRECTIVE]
|
||||
} } from "vue"`
|
||||
)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('module mode preamble w/ optimizeBindings: true', () => {
|
||||
const root = createRoot({
|
||||
helpers: [CREATE_VNODE, RESOLVE_DIRECTIVE]
|
||||
})
|
||||
const { code } = generate(root, { mode: 'module', optimizeBindings: true })
|
||||
expect(code).toMatch(
|
||||
`import { ${helperNameMap[CREATE_VNODE]}, ${
|
||||
helperNameMap[RESOLVE_DIRECTIVE]
|
||||
} } from "vue"`
|
||||
)
|
||||
expect(code).toMatch(
|
||||
`const _${helperNameMap[CREATE_VNODE]} = ${
|
||||
helperNameMap[CREATE_VNODE]
|
||||
}, _${helperNameMap[RESOLVE_DIRECTIVE]} = ${
|
||||
helperNameMap[RESOLVE_DIRECTIVE]
|
||||
}`
|
||||
)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -88,7 +110,9 @@ describe('compiler: codegen', () => {
|
||||
})
|
||||
expect(code).not.toMatch(`const _Vue = Vue`)
|
||||
expect(code).toMatch(
|
||||
`const { ${helperNameMap[CREATE_VNODE]}, ${
|
||||
`const { ${helperNameMap[CREATE_VNODE]}: _${
|
||||
helperNameMap[CREATE_VNODE]
|
||||
}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${
|
||||
helperNameMap[RESOLVE_DIRECTIVE]
|
||||
} } = Vue`
|
||||
)
|
||||
@@ -415,9 +439,9 @@ describe('compiler: codegen', () => {
|
||||
expect(code).toMatch(
|
||||
`
|
||||
_cache[1] || (
|
||||
setBlockTracking(-1),
|
||||
_setBlockTracking(-1),
|
||||
_cache[1] = foo,
|
||||
setBlockTracking(1),
|
||||
_setBlockTracking(1),
|
||||
_cache[1]
|
||||
)
|
||||
`.trim()
|
||||
|
||||
@@ -18,8 +18,8 @@ describe('scopeId compiler support', () => {
|
||||
scopeId: 'test'
|
||||
})
|
||||
expect(ast.helpers).toContain(WITH_SCOPE_ID)
|
||||
expect(code).toMatch(`const withId = withScopeId("test")`)
|
||||
expect(code).toMatch(`export const render = withId(function render() {`)
|
||||
expect(code).toMatch(`const _withId = _withScopeId("test")`)
|
||||
expect(code).toMatch(`export const render = _withId(function render() {`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('scopeId compiler support', () => {
|
||||
mode: 'module',
|
||||
scopeId: 'test'
|
||||
})
|
||||
expect(code).toMatch(`default: withId(() => [`)
|
||||
expect(code).toMatch(`default: _withId(() => [`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -44,8 +44,8 @@ describe('scopeId compiler support', () => {
|
||||
scopeId: 'test'
|
||||
}
|
||||
)
|
||||
expect(code).toMatch(`foo: withId(({ msg }) => [`)
|
||||
expect(code).toMatch(`bar: withId(() => [`)
|
||||
expect(code).toMatch(`foo: _withId(({ msg }) => [`)
|
||||
expect(code).toMatch(`bar: _withId(() => [`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -61,8 +61,8 @@ describe('scopeId compiler support', () => {
|
||||
scopeId: 'test'
|
||||
}
|
||||
)
|
||||
expect(code).toMatch(/name: "foo",\s+fn: withId\(/)
|
||||
expect(code).toMatch(/name: i,\s+fn: withId\(/)
|
||||
expect(code).toMatch(/name: "foo",\s+fn: _withId\(/)
|
||||
expect(code).toMatch(/name: i,\s+fn: _withId\(/)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -80,10 +80,10 @@ describe('scopeId compiler support', () => {
|
||||
expect(ast.hoists.length).toBe(2)
|
||||
expect(code).toMatch(
|
||||
[
|
||||
`pushScopeId("test")`,
|
||||
`const _hoisted_1 = createVNode("div", null, "hello")`,
|
||||
`const _hoisted_2 = createVNode("div", null, "world")`,
|
||||
`popScopeId()`
|
||||
`_pushScopeId("test")`,
|
||||
`const _hoisted_1 = _createVNode("div", null, "hello")`,
|
||||
`const _hoisted_2 = _createVNode("div", null, "world")`,
|
||||
`_popScopeId()`
|
||||
].join('\n')
|
||||
)
|
||||
expect(code).toMatchSnapshot()
|
||||
|
||||
@@ -208,14 +208,14 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = `
|
||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
const _cache = _ctx.$cache
|
||||
return (openBlock(), createBlock(\\"div\\", null, [
|
||||
createVNode(\\"div\\", null, [
|
||||
createVNode(\\"div\\", {
|
||||
return (_openBlock(), _createBlock(\\"div\\", null, [
|
||||
_createVNode(\\"div\\", null, [
|
||||
_createVNode(\\"div\\", {
|
||||
onClick: _cache[1] || (_cache[1] = $event => (_ctx.foo($event)))
|
||||
})
|
||||
])
|
||||
|
||||
@@ -91,10 +91,10 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform text with prefixIdentifiers: true 1`] = `
|
||||
"const { toDisplayString } = Vue
|
||||
"const { toDisplayString: _toDisplayString } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
return toDisplayString(_ctx.foo) + \\" bar \\" + toDisplayString(_ctx.baz + _ctx.qux)
|
||||
return _toDisplayString(_ctx.foo) + \\" bar \\" + _toDisplayString(_ctx.baz + _ctx.qux)
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
|
||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"input\\", {
|
||||
return (_openBlock(), _createBlock(\\"input\\", {
|
||||
modelValue: _ctx.model[_ctx.index],
|
||||
\\"onUpdate:modelValue\\": $event => (_ctx.model[_ctx.index] = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
|
||||
@@ -28,11 +28,11 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform v-model simple exprssion (with prefixIdentifiers) 1`] = `
|
||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"input\\", {
|
||||
return (_openBlock(), _createBlock(\\"input\\", {
|
||||
modelValue: _ctx.model,
|
||||
\\"onUpdate:modelValue\\": $event => (_ctx.model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
|
||||
@@ -70,11 +70,11 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
|
||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||
"import { createVNode as _createVNode, createBlock as _createBlock, openBlock as _openBlock } from \\"vue\\"
|
||||
|
||||
export function render() {
|
||||
const _ctx = this
|
||||
return (openBlock(), createBlock(\\"input\\", {
|
||||
return (_openBlock(), _createBlock(\\"input\\", {
|
||||
[_ctx.value]: _ctx.model,
|
||||
[\\"onUpdate:\\" + _ctx.value]: $event => (_ctx.model = $event)
|
||||
}, null, 16 /* FULL_PROPS */))
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`compiler: transform component slots dynamically named slots 1`] = `
|
||||
"const { toDisplayString, resolveComponent, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, {
|
||||
[_ctx.one]: ({ foo }) => [toDisplayString(foo), toDisplayString(_ctx.bar)],
|
||||
[_ctx.two]: ({ bar }) => [toDisplayString(_ctx.foo), toDisplayString(bar)],
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, {
|
||||
[_ctx.one]: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
|
||||
[_ctx.two]: ({ bar }) => [_toDisplayString(_ctx.foo), _toDisplayString(bar)],
|
||||
_compiled: true
|
||||
}, 512 /* DYNAMIC_SLOTS */))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots implicit default slot 1`] = `
|
||||
"const { createVNode, resolveComponent, createBlock, openBlock } = Vue
|
||||
"const { createVNode: _createVNode, resolveComponent: _resolveComponent, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, {
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, {
|
||||
default: () => [
|
||||
createVNode(\\"div\\")
|
||||
_createVNode(\\"div\\")
|
||||
],
|
||||
_compiled: true
|
||||
}))
|
||||
@@ -32,17 +32,17 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots named slot with v-for w/ prefixIdentifiers: true 1`] = `
|
||||
"const { toDisplayString, resolveComponent, renderList, createSlots, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, renderList: _renderList, createSlots: _createSlots, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, createSlots({ _compiled: true }, [
|
||||
renderList(_ctx.list, (name) => {
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
|
||||
_renderList(_ctx.list, (name) => {
|
||||
return {
|
||||
name: name,
|
||||
fn: () => [toDisplayString(name)]
|
||||
fn: () => [_toDisplayString(name)]
|
||||
}
|
||||
})
|
||||
]), 512 /* DYNAMIC_SLOTS */))
|
||||
@@ -50,17 +50,17 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots named slot with v-if + prefixIdentifiers: true 1`] = `
|
||||
"const { toDisplayString, resolveComponent, createSlots, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, createSlots: _createSlots, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, createSlots({ _compiled: true }, [
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
|
||||
(_ctx.ok)
|
||||
? {
|
||||
name: \\"one\\",
|
||||
fn: (props) => [toDisplayString(props)]
|
||||
fn: (props) => [_toDisplayString(props)]
|
||||
}
|
||||
: undefined
|
||||
]), 512 /* DYNAMIC_SLOTS */))
|
||||
@@ -118,15 +118,15 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots named slots 1`] = `
|
||||
"const { toDisplayString, resolveComponent, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, {
|
||||
one: ({ foo }) => [toDisplayString(foo), toDisplayString(_ctx.bar)],
|
||||
two: ({ bar }) => [toDisplayString(_ctx.foo), toDisplayString(bar)],
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, {
|
||||
one: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
|
||||
two: ({ bar }) => [_toDisplayString(_ctx.foo), _toDisplayString(bar)],
|
||||
_compiled: true
|
||||
}))
|
||||
}"
|
||||
@@ -154,23 +154,23 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots nested slots scoping 1`] = `
|
||||
"const { toDisplayString, resolveComponent, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Inner = resolveComponent(\\"Inner\\")
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Inner = _resolveComponent(\\"Inner\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, {
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, {
|
||||
default: ({ foo }) => [
|
||||
createVNode(_component_Inner, null, {
|
||||
default: ({ bar }) => [toDisplayString(foo), toDisplayString(bar), toDisplayString(_ctx.baz)],
|
||||
_createVNode(_component_Inner, null, {
|
||||
default: ({ bar }) => [_toDisplayString(foo), _toDisplayString(bar), _toDisplayString(_ctx.baz)],
|
||||
_compiled: true
|
||||
}, 512 /* DYNAMIC_SLOTS */),
|
||||
\\" \\",
|
||||
toDisplayString(foo),
|
||||
toDisplayString(_ctx.bar),
|
||||
toDisplayString(_ctx.baz)
|
||||
_toDisplayString(foo),
|
||||
_toDisplayString(_ctx.bar),
|
||||
_toDisplayString(_ctx.baz)
|
||||
],
|
||||
_compiled: true
|
||||
}))
|
||||
@@ -178,14 +178,14 @@ return function render() {
|
||||
`;
|
||||
|
||||
exports[`compiler: transform component slots on-component default slot 1`] = `
|
||||
"const { toDisplayString, resolveComponent, createVNode, createBlock, openBlock } = Vue
|
||||
"const { toDisplayString: _toDisplayString, resolveComponent: _resolveComponent, createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = Vue
|
||||
|
||||
return function render() {
|
||||
const _ctx = this
|
||||
const _component_Comp = resolveComponent(\\"Comp\\")
|
||||
const _component_Comp = _resolveComponent(\\"Comp\\")
|
||||
|
||||
return (openBlock(), createBlock(_component_Comp, null, {
|
||||
default: ({ foo }) => [toDisplayString(foo), toDisplayString(_ctx.bar)],
|
||||
return (_openBlock(), _createBlock(_component_Comp, null, {
|
||||
default: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
|
||||
_compiled: true
|
||||
}))
|
||||
}"
|
||||
|
||||
@@ -196,7 +196,7 @@ export function generate(
|
||||
|
||||
// enter render function
|
||||
if (genScopeId && !ssr) {
|
||||
push(`const render = withId(`)
|
||||
push(`const render = _withId(`)
|
||||
}
|
||||
if (!ssr) {
|
||||
push(`function render() {`)
|
||||
@@ -395,7 +395,7 @@ function genModulePreamble(
|
||||
}
|
||||
|
||||
if (genScopeId) {
|
||||
push(`const withId = ${helper(WITH_SCOPE_ID)}("${scopeId}")`)
|
||||
push(`const _withId = ${helper(WITH_SCOPE_ID)}("${scopeId}")`)
|
||||
newline()
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ function genFunctionExpression(
|
||||
!__BROWSER__ && isSlot && scopeId != null && mode !== 'function'
|
||||
|
||||
if (genScopeId) {
|
||||
push(`withId(`)
|
||||
push(`_withId(`)
|
||||
}
|
||||
push(`(`, node)
|
||||
if (isArray(params)) {
|
||||
|
||||
Reference in New Issue
Block a user