"
return function render(_ctx, _cache) {
with (_ctx) {
- return _createVNode(\\"div\\", {
+ return _createElementVNode(\\"div\\", {
id: \\"foo\\",
[prop]: bar,
[foo + bar]: bar
}, [
- _createVNode(\\"p\\", { \\"some-key\\": \\"foo\\" })
+ _createElementVNode(\\"p\\", { \\"some-key\\": \\"foo\\" })
], 16)
}
}"
"
return function render(_ctx, _cache) {
with (_ctx) {
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(), 1))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(), 1))
}
}"
`;
"
return function render(_ctx, _cache) {
with (_ctx) {
- return (_openBlock(), _createBlock(_Fragment, null, _renderList(), 64 /* STABLE_FRAGMENT */))
+ return (_openBlock(), _createElementBlock(_Fragment, null, _renderList(), 64 /* STABLE_FRAGMENT */))
}
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createVNode: _createVNode } = _Vue
+ const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createElementVNode: _createElementVNode, normalizeClass: _normalizeClass } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", {
+ return (_openBlock(), _createElementBlock(\\"div\\", {
id: \\"foo\\",
- class: bar.baz
+ class: _normalizeClass(bar.baz)
}, [
_createTextVNode(_toDisplayString(world.burn()) + \\" \\", 1 /* TEXT */),
ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
- : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\"))
+ : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\")
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)),
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => {
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (value, index) => {
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
]))
}), 256 /* UNKEYED_FRAGMENT */))
], 2 /* CLASS */))
`;
exports[`compiler: integration tests function mode w/ prefixIdentifiers: true 1`] = `
-"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createVNode: _createVNode } = Vue
+"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createElementVNode: _createElementVNode, normalizeClass: _normalizeClass } = Vue
return function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"div\\", {
+ return (_openBlock(), _createElementBlock(\\"div\\", {
id: \\"foo\\",
- class: _ctx.bar.baz
+ class: _normalizeClass(_ctx.bar.baz)
}, [
_createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
(_ctx.ok)
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
- : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\"))
+ : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\")
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)),
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
]))
}), 256 /* UNKEYED_FRAGMENT */))
], 2 /* CLASS */))
`;
exports[`compiler: integration tests module mode 1`] = `
-"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, Fragment as _Fragment, renderList as _renderList, createVNode as _createVNode } from \\"vue\\"
+"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, Fragment as _Fragment, renderList as _renderList, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"div\\", {
+ return (_openBlock(), _createElementBlock(\\"div\\", {
id: \\"foo\\",
- class: _ctx.bar.baz
+ class: _normalizeClass(_ctx.bar.baz)
}, [
_createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */),
(_ctx.ok)
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\"))
- : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\"))
+ : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [
_createTextVNode(\\"no\\")
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)),
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => {
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */)
]))
}), 256 /* UNKEYED_FRAGMENT */))
], 2 /* CLASS */))
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`scopeId compiler support should push scopeId for hoisted nodes 1`] = `
-"import { createVNode as _createVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"test\\")
_pushScopeId(\\"test\\")
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */)
-const _hoisted_2 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"world\\", -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */)
+const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"world\\", -1 /* HOISTED */)
_popScopeId()
export const render = /*#__PURE__*/_withId((_ctx, _cache) => {
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1,
_createTextVNode(_toDisplayString(_ctx.foo), 1 /* TEXT */),
_hoisted_2
`;
exports[`scopeId compiler support should wrap default slot 1`] = `
-"import { createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"test\\")
export const render = /*#__PURE__*/_withId((_ctx, _cache) => {
return (_openBlock(), _createBlock(_component_Child, null, {
default: _withId(() => [
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
]),
_: 1 /* STABLE */
}))
`;
exports[`scopeId compiler support should wrap dynamic slots 1`] = `
-"import { createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"test\\")
export const render = /*#__PURE__*/_withId((_ctx, _cache) => {
? {
name: \\"foo\\",
fn: _withId(() => [
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
])
}
: undefined,
return {
name: i,
fn: _withId(() => [
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
])
}
})
`;
exports[`scopeId compiler support should wrap named slots 1`] = `
-"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
+"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"test\\")
export const render = /*#__PURE__*/_withId((_ctx, _cache) => {
_createTextVNode(_toDisplayString(msg), 1 /* TEXT */)
]),
bar: _withId(() => [
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
]),
_: 1 /* STABLE */
}))
RESOLVE_COMPONENT,
CREATE_COMMENT,
FRAGMENT,
- RENDER_LIST
+ RENDER_LIST,
+ CREATE_ELEMENT_VNODE
} from '../src/runtimeHelpers'
import { createElementWithCodegen, genFlagText } from './testUtils'
import { PatchFlags } from '@vue/shared'
})
)
expect(code).toMatch(`
- return _${helperNameMap[CREATE_VNODE]}("div", {
+ return _${helperNameMap[CREATE_ELEMENT_VNODE]}("div", {
id: "foo",
[prop]: bar,
[foo + bar]: bar
}, [
- _${helperNameMap[CREATE_VNODE]}("p", { "some-key": "foo" })
+ _${helperNameMap[CREATE_ELEMENT_VNODE]}("p", { "some-key": "foo" })
], ${PatchFlags.FULL_PROPS})`)
expect(code).toMatchSnapshot()
})
test('tag only', () => {
expect(genCode(createVNodeCall(null, `"div"`))).toMatchInlineSnapshot(`
- "return _createVNode(\\"div\\")
+ "return _createElementVNode(\\"div\\")
"
`)
expect(genCode(createVNodeCall(null, FRAGMENT))).toMatchInlineSnapshot(`
- "return _createVNode(_Fragment)
+ "return _createElementVNode(_Fragment)
"
`)
})
test('with props', () => {
expect(genCode(createVNodeCall(null, `"div"`, mockProps)))
.toMatchInlineSnapshot(`
- "return _createVNode(\\"div\\", { foo: \\"bar\\" })
+ "return _createElementVNode(\\"div\\", { foo: \\"bar\\" })
"
`)
})
test('with children, no props', () => {
expect(genCode(createVNodeCall(null, `"div"`, undefined, mockChildren)))
.toMatchInlineSnapshot(`
- "return _createVNode(\\"div\\", null, children)
+ "return _createElementVNode(\\"div\\", null, children)
"
`)
})
test('with children + props', () => {
expect(genCode(createVNodeCall(null, `"div"`, mockProps, mockChildren)))
.toMatchInlineSnapshot(`
- "return _createVNode(\\"div\\", { foo: \\"bar\\" }, children)
+ "return _createElementVNode(\\"div\\", { foo: \\"bar\\" }, children)
"
`)
})
test('with patchFlag and no children/props', () => {
expect(genCode(createVNodeCall(null, `"div"`, undefined, undefined, '1')))
.toMatchInlineSnapshot(`
- "return _createVNode(\\"div\\", null, null, 1)
+ "return _createElementVNode(\\"div\\", null, null, 1)
"
`)
})
)
)
).toMatchInlineSnapshot(`
- "return (_openBlock(), _createBlock(\\"div\\", { foo: \\"bar\\" }, children))
+ "return (_openBlock(), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children))
"
`)
})
)
)
).toMatchInlineSnapshot(`
- "return (_openBlock(true), _createBlock(\\"div\\", { foo: \\"bar\\" }, children))
+ "return (_openBlock(true), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children))
"
`)
})
)
)
).toMatchInlineSnapshot(`
- "return _withDirectives(_createVNode(\\"div\\", { foo: \\"bar\\" }, children), [
+ "return _withDirectives(_createElementVNode(\\"div\\", { foo: \\"bar\\" }, children), [
[foo, bar]
])
"
)
)
).toMatchInlineSnapshot(`
- "return _withDirectives((_openBlock(), _createBlock(\\"div\\", { foo: \\"bar\\" }, children)), [
+ "return _withDirectives((_openBlock(), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children)), [
[foo, bar]
])
"
expect(code).toMatch(
[
`_pushScopeId("test")`,
- `const _hoisted_1 = /*#__PURE__*/_createVNode("div", null, "hello", ${genFlagText(
+ `const _hoisted_1 = /*#__PURE__*/_createElementVNode("div", null, "hello", ${genFlagText(
PatchFlags.HOISTED
)})`,
- `const _hoisted_2 = /*#__PURE__*/_createVNode("div", null, "world", ${genFlagText(
+ `const _hoisted_2 = /*#__PURE__*/_createElementVNode("div", null, "world", ${genFlagText(
PatchFlags.HOISTED
)})`,
`_popScopeId()`
ElementTypes,
VNodeCall
} from '../src'
-import { isString, PatchFlags, PatchFlagNames, isArray } from '@vue/shared'
+import {
+ isString,
+ PatchFlags,
+ PatchFlagNames,
+ isArray,
+ ShapeFlags
+} from '@vue/shared'
const leadingBracketRE = /^\[/
const bracketsRE = /^\[|\]$/g
directives: undefined,
isBlock: false,
disableTracking: false,
+ isComponent: false,
+ shapeFlag: ShapeFlags.ELEMENT + ``,
loc: locStub
}
}
}
-export function genFlagText(flag: PatchFlags | PatchFlags[]) {
+type Flags = PatchFlags | ShapeFlags
+export function genFlagText(
+ flag: Flags | Flags[],
+ names: { [k: number]: string } = PatchFlagNames
+) {
if (isArray(flag)) {
let f = 0
flag.forEach(ff => {
f |= ff
})
- return `${f} /* ${flag.map(f => PatchFlagNames[f]).join(', ')} */`
+ return `${f} /* ${flag.map(f => names[f]).join(', ')} */`
} else {
- return `${flag} /* ${PatchFlagNames[flag]} */`
+ return `${flag} /* ${names[flag]} */`
}
}
exports[`compiler: hoistStatic transform hoist element with static key 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
exports[`compiler: hoistStatic transform hoist nested static tree 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"p\\", null, [
- /*#__PURE__*/_createVNode(\\"span\\"),
- /*#__PURE__*/_createVNode(\\"span\\")
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"p\\", null, [
+ /*#__PURE__*/_createElementVNode(\\"span\\"),
+ /*#__PURE__*/_createElementVNode(\\"span\\")
], -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
exports[`compiler: hoistStatic transform hoist nested static tree with comments 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue
+const { createElementVNode: _createElementVNode, createCommentVNode: _createCommentVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, [
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, [
/*#__PURE__*/_createCommentVNode(\\"comment\\")
], -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createCommentVNode: _createCommentVNode, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createCommentVNode: _createCommentVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
exports[`compiler: hoistStatic transform hoist siblings with common non-hoistable parent 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */)
-const _hoisted_2 = /*#__PURE__*/_createVNode(\\"div\\", null, null, -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
+const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"div\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1,
_hoisted_2
]))
exports[`compiler: hoistStatic transform hoist simple element 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
exports[`compiler: hoistStatic transform hoist static props for elements with directives 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
with (_ctx) {
- const { resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { resolveDirective: _resolveDirective, createElementVNode: _createElementVNode, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _directive_foo = _resolveDirective(\\"foo\\")
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _withDirectives(_createVNode(\\"div\\", _hoisted_1, null, 512 /* NEED_PATCH */), [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _withDirectives(_createElementVNode(\\"div\\", _hoisted_1, null, 512 /* NEED_PATCH */), [
[_directive_foo]
])
]))
exports[`compiler: hoistStatic transform hoist static props for elements with dynamic text children 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", _hoisted_1, _toDisplayString(hello), 1 /* TEXT */)
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"div\\", _hoisted_1, _toDisplayString(hello), 1 /* TEXT */)
]))
}
}"
exports[`compiler: hoistStatic transform hoist static props for elements with unhoistable children 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createVNode: _createVNode, createElementVNode: _createElementVNode } = _Vue
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
with (_ctx) {
- const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { resolveComponent: _resolveComponent, createVNode: _createVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", _hoisted_1, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"div\\", _hoisted_1, [
_createVNode(_component_Comp)
])
]))
exports[`compiler: hoistStatic transform prefixIdentifiers hoist class with static object value 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = { class: { foo: true } }
+const _hoisted_1 = {
+ class: /*#__PURE__*/_normalizeClass({ foo: true })
+}
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, normalizeClass: _normalizeClass, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"span\\", _hoisted_1, _toDisplayString(_ctx.bar), 1 /* TEXT */)
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"span\\", _hoisted_1, _toDisplayString(_ctx.bar), 1 /* TEXT */)
]))
}
}"
exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static tree with static interpolation 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", null, \\"foo \\" + /*#__PURE__*/_toDisplayString(1) + \\" \\" + /*#__PURE__*/_toDisplayString(true), -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, \\"foo \\" + /*#__PURE__*/_toDisplayString(1) + \\" \\" + /*#__PURE__*/_toDisplayString(true), -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static tree with static prop value 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", { foo: 0 }, /*#__PURE__*/_toDisplayString(1), -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { foo: 0 }, /*#__PURE__*/_toDisplayString(1), -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_hoisted_1
]))
}
`;
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = `
-"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", null, [
- _createVNode(\\"div\\", {
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"div\\", null, [
+ _createElementVNode(\\"div\\", {
onClick: _cache[1] || (_cache[1] = (...args) => (_ctx.foo && _ctx.foo(...args)))
})
])
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, toDisplayString: _toDisplayString, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
- return (_openBlock(), _createBlock(\\"p\\", null, [
- _createVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */)
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
+ return (_openBlock(), _createElementBlock(\\"p\\", null, [
+ _createElementVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */)
]))
}), 256 /* UNKEYED_FRAGMENT */))
]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, toDisplayString: _toDisplayString, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
- return (_openBlock(), _createBlock(\\"p\\", null, [
- _createVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */)
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (o) => {
+ return (_openBlock(), _createElementBlock(\\"p\\", null, [
+ _createElementVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */)
]))
}), 256 /* UNKEYED_FRAGMENT */))
]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(\\"span\\", { key: item }))
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(\\"span\\", { key: item }))
}), 128 /* KEYED_FRAGMENT */))
]))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_createVNode(_component_Comp)
]))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- (_openBlock(), _createBlock(\\"div\\", { key: foo }))
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ (_openBlock(), _createElementBlock(\\"div\\", { key: foo }))
]))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"])
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"])
]))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", { ref: foo }, null, 512 /* NEED_PATCH */)
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ _createElementVNode(\\"div\\", { ref: foo }, null, 512 /* NEED_PATCH */)
]))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\"))
+ return (_openBlock(), _createElementBlock(\\"div\\"))
}
}"
`;
exports[`compiler: hoistStatic transform should hoist v-for children if static 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode } = _Vue
+const { createElementVNode: _createElementVNode } = _Vue
const _hoisted_1 = { id: \\"foo\\" }
-const _hoisted_2 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */)
+const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
- (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
- return (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (i) => {
+ return (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [
_hoisted_2
]))
}), 256 /* UNKEYED_FRAGMENT */))
exports[`compiler: hoistStatic transform should hoist v-if props/children if static 1`] = `
"const _Vue = Vue
-const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue
+const { createElementVNode: _createElementVNode, createCommentVNode: _createCommentVNode } = _Vue
const _hoisted_1 = {
key: 0,
id: \\"foo\\"
}
-const _hoisted_2 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */)
+const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
ok
- ? (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [
+ ? (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [
_hoisted_2
]))
: _createCommentVNode(\\"v-if\\", true)
exports[`compiler: expression transform bindingMetadata inline mode 1`] = `
"(_ctx, _cache) => {
- return (_openBlock(), _createBlock(\\"div\\", null, _toDisplayString(__props.props) + \\" \\" + _toDisplayString(_unref(setup)) + \\" \\" + _toDisplayString(setupConst) + \\" \\" + _toDisplayString(_ctx.data) + \\" \\" + _toDisplayString(_ctx.options), 1 /* TEXT */))
+ return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString(__props.props) + \\" \\" + _toDisplayString(_unref(setup)) + \\" \\" + _toDisplayString(setupConst) + \\" \\" + _toDisplayString(_ctx.data) + \\" \\" + _toDisplayString(_ctx.options), 1 /* TEXT */))
}"
`;
exports[`compiler: expression transform bindingMetadata non-inline mode 1`] = `
-"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock } = Vue
+"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
return function render(_ctx, _cache, $props, $setup, $data, $options) {
- return (_openBlock(), _createBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options), 1 /* TEXT */))
+ return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options), 1 /* TEXT */))
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createTextVNode: _createTextVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createTextVNode: _createTextVNode } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (i) => {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
_createTextVNode(\\"foo\\")
], 64 /* STABLE_FRAGMENT */))
}), 256 /* UNKEYED_FRAGMENT */))
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\"),
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\"),
_createTextVNode(_toDisplayString(foo) + \\" bar \\" + _toDisplayString(baz), 1 /* TEXT */),
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
], 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\"),
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\"),
_createTextVNode(_toDisplayString(foo) + \\" bar \\" + _toDisplayString(baz), 1 /* TEXT */),
- _createVNode(\\"div\\"),
+ _createElementVNode(\\"div\\"),
_createTextVNode(\\"hello\\"),
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
], 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _directive_foo = _resolveDirective(\\"foo\\")
- return _withDirectives((_openBlock(), _createBlock(\\"p\\", null, [
+ return _withDirectives((_openBlock(), _createElementBlock(\\"p\\", null, [
_createTextVNode(_toDisplayString(foo), 1 /* TEXT */)
], 512 /* NEED_PATCH */)), [
[_directive_foo]
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\"),
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\"),
_createTextVNode(\\"hello\\"),
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
], 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(\\"span\\"))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(\\"span\\"))
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(_Fragment, { key: item }, [
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(_Fragment, { key: item }, [
\\"hello\\",
- _createVNode(\\"span\\")
+ _createElementVNode(\\"span\\")
], 64 /* STABLE_FRAGMENT */))
}), 128 /* KEYED_FRAGMENT */))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(\\"span\\", { key: item }))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(\\"span\\", { key: item }))
}), 128 /* KEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
- return (_openBlock(), _createBlock(\\"span\\"))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item, __, index) => {
+ return (_openBlock(), _createElementBlock(\\"span\\"))
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
- return (_openBlock(), _createBlock(\\"span\\"))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (_, __, index) => {
+ return (_openBlock(), _createElementBlock(\\"span\\"))
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
- return (_openBlock(), _createBlock(\\"span\\"))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (_, key, index) => {
+ return (_openBlock(), _createElementBlock(\\"span\\"))
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
\\"hello\\",
- _createVNode(\\"span\\")
+ _createElementVNode(\\"span\\")
], 64 /* STABLE_FRAGMENT */))
}), 256 /* UNKEYED_FRAGMENT */))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
- return (_openBlock(), _createBlock(\\"span\\", {
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(), _createElementBlock(\\"span\\", {
key: item.id,
id: item.id
}, null, 8 /* PROPS */, [\\"id\\"]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, renderSlot: _renderSlot } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
return _renderSlot($slots, \\"default\\")
}), 256 /* UNKEYED_FRAGMENT */))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, renderSlot: _renderSlot } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {
return _renderSlot($slots, \\"default\\")
}), 256 /* UNKEYED_FRAGMENT */))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, resolveDirective: _resolveDirective, withDirectives: _withDirectives } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, resolveDirective: _resolveDirective, withDirectives: _withDirectives } = _Vue
const _directive_foo = _resolveDirective(\\"foo\\")
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
- return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (i) => {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
[_directive_foo]
])
}), 256 /* UNKEYED_FRAGMENT */))
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, toDisplayString: _toDisplayString, createElementVNode: _createElementVNode } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, _renderList(10, (item) => {
- return _createVNode(\\"p\\", null, _toDisplayString(item), 1 /* TEXT */)
+ return (_openBlock(), _createElementBlock(_Fragment, null, _renderList(10, (item) => {
+ return _createElementVNode(\\"p\\", null, _toDisplayString(item), 1 /* TEXT */)
}), 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(true), _createBlock(_Fragment, { key: 0 }, _renderList(list, (i) => {
- return (_openBlock(), _createBlock(\\"div\\"))
+ ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(list, (i) => {
+ return (_openBlock(), _createElementBlock(\\"div\\"))
}), 256 /* UNKEYED_FRAGMENT */))
: _createCommentVNode(\\"v-if\\", true)
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(true), _createBlock(_Fragment, { key: 0 }, _renderList(list, (i) => {
- return (_openBlock(), _createBlock(_Fragment, null, [], 64 /* STABLE_FRAGMENT */))
+ ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(list, (i) => {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [], 64 /* STABLE_FRAGMENT */))
}), 256 /* UNKEYED_FRAGMENT */))
: _createCommentVNode(\\"v-if\\", true)
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
- return (_openBlock(), _createBlock(\\"span\\"))
+ return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item, key, index) => {
+ return (_openBlock(), _createElementBlock(\\"span\\"))
}), 256 /* UNKEYED_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
: _createCommentVNode(\\"v-if\\", true)
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
- : (_openBlock(), _createBlock(\\"p\\", { key: 1 })),
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
+ : (_openBlock(), _createElementBlock(\\"p\\", { key: 1 })),
another
- ? (_openBlock(), _createBlock(\\"div\\", { key: 2 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 2 }))
: orNot
- ? (_openBlock(), _createBlock(\\"p\\", { key: 3 }))
- : (_openBlock(), _createBlock(\\"p\\", { key: 4 }))
+ ? (_openBlock(), _createElementBlock(\\"p\\", { key: 3 }))
+ : (_openBlock(), _createElementBlock(\\"p\\", { key: 4 }))
], 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
: _createCommentVNode(\\"v-if\\", true),
orNot
- ? (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
+ ? (_openBlock(), _createElementBlock(\\"p\\", { key: 1 }))
: _createCommentVNode(\\"v-if\\", true)
], 64 /* STABLE_FRAGMENT */))
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { createElementVNode: _createElementVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(), _createBlock(_Fragment, { key: 0 }, [
- _createVNode(\\"div\\"),
+ ? (_openBlock(), _createElementBlock(_Fragment, { key: 0 }, [
+ _createElementVNode(\\"div\\"),
\\"hello\\",
- _createVNode(\\"p\\")
+ _createElementVNode(\\"p\\")
], 64 /* STABLE_FRAGMENT */))
: _createCommentVNode(\\"v-if\\", true)
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
- : (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
+ : (_openBlock(), _createElementBlock(\\"p\\", { key: 1 }))
}
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
return ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
: orNot
- ? (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
- : (_openBlock(), _createBlock(_Fragment, { key: 2 }, [\\"fine\\"], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
+ ? (_openBlock(), _createElementBlock(\\"p\\", { key: 1 }))
+ : (_openBlock(), _createElementBlock(_Fragment, { key: 2 }, [\\"fine\\"], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
}
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }))
: orNot
- ? (_openBlock(), _createBlock(\\"p\\", { key: 1 }))
+ ? (_openBlock(), _createElementBlock(\\"p\\", { key: 1 }))
: _createCommentVNode(\\"v-if\\", true)
}
}"
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
modelValue: _ctx.model[_ctx.index],
\\"onUpdate:modelValue\\": $event => (_ctx.model[_ctx.index] = $event)
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
modelValue: model[index],
\\"onUpdate:modelValue\\": $event => (model[index] = $event)
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
modelValue:
model
.
`;
exports[`compiler: transform v-model simple expression (with prefixIdentifiers) 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
modelValue: _ctx.model,
\\"onUpdate:modelValue\\": $event => (_ctx.model = $event)
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
modelValue: model,
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", {
value: model,
\\"onUpdate:value\\": $event => (model = $event)
}, null, 40 /* PROPS, HYDRATE_EVENTS */, [\\"value\\", \\"onUpdate:value\\"]))
`;
exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { normalizeProps as _normalizeProps, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", _normalizeProps({
[_ctx.value]: _ctx.model,
[\\"onUpdate:\\" + _ctx.value]: $event => (_ctx.model = $event)
- }, null, 16 /* FULL_PROPS */))
+ }), null, 16 /* FULL_PROPS */))
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { normalizeProps: _normalizeProps, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"input\\", {
+ return (_openBlock(), _createElementBlock(\\"input\\", _normalizeProps({
[value]: model,
[\\"onUpdate:\\" + value]: $event => (model = $event)
- }, null, 16 /* FULL_PROPS */))
+ }), null, 16 /* FULL_PROPS */))
}
}"
`;
return function render(_ctx, _cache) {
with (_ctx) {
- const { setBlockTracking: _setBlockTracking, createVNode: _createVNode } = _Vue
+ const { setBlockTracking: _setBlockTracking, createElementVNode: _createElementVNode } = _Vue
return _cache[1] || (
_setBlockTracking(-1),
- _cache[1] = _createVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]),
+ _cache[1] = _createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]),
_setBlockTracking(1),
_cache[1]
)
return function render(_ctx, _cache) {
with (_ctx) {
- const { setBlockTracking: _setBlockTracking, resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { setBlockTracking: _setBlockTracking, resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_cache[1] || (
_setBlockTracking(-1),
_cache[1] = _createVNode(_component_Comp, { id: foo }, null, 8 /* PROPS */, [\\"id\\"]),
return function render(_ctx, _cache) {
with (_ctx) {
- const { setBlockTracking: _setBlockTracking, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { setBlockTracking: _setBlockTracking, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_cache[1] || (
_setBlockTracking(-1),
- _cache[1] = _createVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]),
+ _cache[1] = _createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]),
_setBlockTracking(1),
_cache[1]
)
return function render(_ctx, _cache) {
with (_ctx) {
- const { setBlockTracking: _setBlockTracking, renderSlot: _renderSlot, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { setBlockTracking: _setBlockTracking, renderSlot: _renderSlot, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_cache[1] || (
_setBlockTracking(-1),
_cache[1] = _renderSlot($slots, \\"default\\"),
return function render(_ctx, _cache) {
with (_ctx) {
- const { setBlockTracking: _setBlockTracking, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { setBlockTracking: _setBlockTracking, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(\\"div\\", null, [
+ return (_openBlock(), _createElementBlock(\\"div\\", null, [
_cache[1] || (
_setBlockTracking(-1),
- _cache[1] = _createVNode(\\"div\\"),
+ _cache[1] = _createElementVNode(\\"div\\"),
_setBlockTracking(1),
_cache[1]
)
`;
exports[`compiler: transform component slots implicit default slot 1`] = `
-"const { createVNode: _createVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = Vue
+"const { createElementVNode: _createElementVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = Vue
return function render(_ctx, _cache) {
const _component_Comp = _resolveComponent(\\"Comp\\")
return (_openBlock(), _createBlock(_component_Comp, null, {
default: _withCtx(() => [
- _createVNode(\\"div\\")
+ _createElementVNode(\\"div\\")
]),
_: 1 /* STABLE */
}))
return function render(_ctx, _cache) {
with (_ctx) {
- const { createVNode: _createVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { createElementVNode: _createElementVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
one: _withCtx(() => [\\"foo\\"]),
default: _withCtx(() => [
\\"bar\\",
- _createVNode(\\"span\\")
+ _createElementVNode(\\"span\\")
]),
_: 1 /* STABLE */
}))
`;
exports[`compiler: transform component slots with whitespace: 'preserve' implicit default slot 1`] = `
-"const { createVNode: _createVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = Vue
+"const { createElementVNode: _createElementVNode, resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock } = Vue
return function render(_ctx, _cache) {
const _component_Comp = _resolveComponent(\\"Comp\\")
header: _withCtx(() => [\\" Header \\"]),
default: _withCtx(() => [
\\" \\",
- _createVNode(\\"p\\")
+ _createElementVNode(\\"p\\")
]),
_: 1 /* STABLE */
}))
ForNode,
ConstantTypes
} from '../../src'
-import { FRAGMENT, RENDER_LIST, CREATE_TEXT } from '../../src/runtimeHelpers'
+import {
+ FRAGMENT,
+ RENDER_LIST,
+ CREATE_TEXT,
+ NORMALIZE_CLASS
+} from '../../src/runtimeHelpers'
import { transformElement } from '../../src/transforms/transformElement'
import { transformExpression } from '../../src/transforms/transformExpression'
import { transformIf } from '../../src/transforms/vIf'
constType: ConstantTypes.CAN_STRINGIFY
},
value: {
- content: `{ foo: true }`,
- isStatic: false,
- constType: ConstantTypes.CAN_STRINGIFY
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_CLASS,
+ arguments: [
+ {
+ content: `{ foo: true }`,
+ isStatic: false,
+ constType: ConstantTypes.CAN_STRINGIFY
+ }
+ ]
}
}
]
RESOLVE_DYNAMIC_COMPONENT,
SUSPENSE,
KEEP_ALIVE,
- BASE_TRANSITION
+ BASE_TRANSITION,
+ NORMALIZE_CLASS,
+ NORMALIZE_STYLE,
+ NORMALIZE_PROPS,
+ GUARD_REACTIVE_PROPS
} from '../../src/runtimeHelpers'
import {
NodeTypes,
const { root, node } = parseWithElementTransform(`<div v-bind="obj" />`)
// single v-bind doesn't need mergeProps
expect(root.helpers).not.toContain(MERGE_PROPS)
+ expect(root.helpers).toContain(NORMALIZE_PROPS)
+ expect(root.helpers).toContain(GUARD_REACTIVE_PROPS)
// should directly use `obj` in props position
expect(node.props).toMatchObject({
- type: NodeTypes.SIMPLE_EXPRESSION,
- content: `obj`
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: GUARD_REACTIVE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `obj`
+ }
+ ]
+ }
+ ]
})
})
})
test(`props merging: style`, () => {
- const { node } = parseWithElementTransform(
+ const { node, root } = parseWithElementTransform(
`<div style="color: green" :style="{ color: 'red' }" />`,
{
nodeTransforms: [transformStyle, transformElement],
}
}
)
+ expect(root.helpers).toContain(NORMALIZE_STYLE)
expect(node.props).toMatchObject({
type: NodeTypes.JS_OBJECT_EXPRESSION,
properties: [
isStatic: true
},
value: {
- type: NodeTypes.JS_ARRAY_EXPRESSION,
- elements: [
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_STYLE,
+ arguments: [
{
- type: NodeTypes.SIMPLE_EXPRESSION,
- content: `{"color":"green"}`,
- isStatic: false
- },
- {
- type: NodeTypes.SIMPLE_EXPRESSION,
- content: `{ color: 'red' }`,
- isStatic: false
+ type: NodeTypes.JS_ARRAY_EXPRESSION,
+ elements: [
+ {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `{"color":"green"}`,
+ isStatic: false
+ },
+ {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `{ color: 'red' }`,
+ isStatic: false
+ }
+ ]
}
]
}
})
test(`props merging: class`, () => {
- const { node } = parseWithElementTransform(
+ const { node, root } = parseWithElementTransform(
`<div class="foo" :class="{ bar: isBar }" />`,
{
directiveTransforms: {
}
}
)
+ expect(root.helpers).toContain(NORMALIZE_CLASS)
expect(node.props).toMatchObject({
type: NodeTypes.JS_OBJECT_EXPRESSION,
properties: [
isStatic: true
},
value: {
- type: NodeTypes.JS_ARRAY_EXPRESSION,
- elements: [
- {
- type: NodeTypes.SIMPLE_EXPRESSION,
- content: `foo`,
- isStatic: true
- },
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_CLASS,
+ arguments: [
{
- type: NodeTypes.SIMPLE_EXPRESSION,
- content: `{ bar: isBar }`,
- isStatic: false
+ type: NodeTypes.JS_ARRAY_EXPRESSION,
+ elements: [
+ {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `foo`,
+ isStatic: true
+ },
+ {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `{ bar: isBar }`,
+ isStatic: false
+ }
+ ]
}
]
}
ObjectExpression,
CompilerOptions,
ErrorCodes,
- VNodeCall
+ VNodeCall,
+ NodeTypes,
+ CallExpression
} from '../../src'
import { transformBind } from '../../src/transforms/vBind'
import { transformElement } from '../../src/transforms/transformElement'
-import { CAMELIZE, helperNameMap } from '../../src/runtimeHelpers'
+import {
+ CAMELIZE,
+ helperNameMap,
+ NORMALIZE_PROPS
+} from '../../src/runtimeHelpers'
import { transformExpression } from '../../src/transforms/transformExpression'
function parseWithVBind(
test('dynamic arg', () => {
const node = parseWithVBind(`<div v-bind:[id]="id"/>`)
- const props = (node.codegenNode as VNodeCall).props as ObjectExpression
- expect(props.properties[0]).toMatchObject({
- key: {
- content: `id || ""`,
- isStatic: false
- },
- value: {
- content: `id`,
- isStatic: false
- }
+ const props = (node.codegenNode as VNodeCall).props as CallExpression
+ expect(props).toMatchObject({
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_OBJECT_EXPRESSION,
+ properties: [
+ {
+ key: {
+ content: `id || ""`,
+ isStatic: false
+ },
+ value: {
+ content: `id`,
+ isStatic: false
+ }
+ }
+ ]
+ }
+ ]
})
})
test('.camel modifier w/ dynamic arg', () => {
const node = parseWithVBind(`<div v-bind:[foo].camel="id"/>`)
- const props = (node.codegenNode as VNodeCall).props as ObjectExpression
- expect(props.properties[0]).toMatchObject({
- key: {
- content: `_${helperNameMap[CAMELIZE]}(foo || "")`,
- isStatic: false
- },
- value: {
- content: `id`,
- isStatic: false
- }
+ const props = (node.codegenNode as VNodeCall).props as CallExpression
+ expect(props).toMatchObject({
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_OBJECT_EXPRESSION,
+ properties: [
+ {
+ key: {
+ content: `_${helperNameMap[CAMELIZE]}(foo || "")`,
+ isStatic: false
+ },
+ value: {
+ content: `id`,
+ isStatic: false
+ }
+ }
+ ]
+ }
+ ]
})
})
CREATE_COMMENT,
FRAGMENT,
MERGE_PROPS,
+ NORMALIZE_PROPS,
RENDER_SLOT
} from '../../src/runtimeHelpers'
import { createObjectMatcher } from '../testUtils'
const branch1 = codegenNode.consequent as VNodeCall
expect(branch1.props).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
- callee: MERGE_PROPS,
- arguments: [createObjectMatcher({ key: `[0]` }), { content: `obj` }]
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: MERGE_PROPS,
+ arguments: [createObjectMatcher({ key: `[0]` }), { content: `obj` }]
+ }
+ ]
})
})
PlainElementNode,
ComponentNode,
NodeTypes,
- VNodeCall
+ VNodeCall,
+ NORMALIZE_PROPS
} from '../../src'
import { ErrorCodes } from '../../src/errors'
import { transformModel } from '../../src/transforms/vModel'
import { transformExpression } from '../../src/transforms/transformExpression'
import { transformFor } from '../../src/transforms/vFor'
import { trackSlotScopes } from '../../src/transforms/vSlot'
+import { CallExpression } from '@babel/types'
function parseWithVModel(template: string, options: CompilerOptions = {}) {
const ast = parse(template)
test('with dynamic argument', () => {
const root = parseWithVModel('<input v-model:[value]="model" />')
const node = root.children[0] as ElementNode
- const props = ((node.codegenNode as VNodeCall).props as ObjectExpression)
- .properties
+ const props = ((node.codegenNode as VNodeCall)
+ .props as unknown) as CallExpression
- expect(props[0]).toMatchObject({
- key: {
- content: 'value',
- isStatic: false
- },
- value: {
- content: 'model',
- isStatic: false
- }
- })
-
- expect(props[1]).toMatchObject({
- key: {
- children: [
- '"onUpdate:" + ',
- {
- content: 'value',
- isStatic: false
- }
- ]
- },
- value: {
- children: [
- '$event => (',
- {
- content: 'model',
- isStatic: false
- },
- ' = $event)'
- ]
- }
+ expect(props).toMatchObject({
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_OBJECT_EXPRESSION,
+ properties: [
+ {
+ key: {
+ content: 'value',
+ isStatic: false
+ },
+ value: {
+ content: 'model',
+ isStatic: false
+ }
+ },
+ {
+ key: {
+ children: [
+ '"onUpdate:" + ',
+ {
+ content: 'value',
+ isStatic: false
+ }
+ ]
+ },
+ value: {
+ children: [
+ '$event => (',
+ {
+ content: 'model',
+ isStatic: false
+ },
+ ' = $event)'
+ ]
+ }
+ }
+ ]
+ }
+ ]
})
expect(generate(root).code).toMatchSnapshot()
prefixIdentifiers: true
})
const node = root.children[0] as ElementNode
- const props = ((node.codegenNode as VNodeCall).props as ObjectExpression)
- .properties
+ const props = ((node.codegenNode as VNodeCall)
+ .props as unknown) as CallExpression
- expect(props[0]).toMatchObject({
- key: {
- content: '_ctx.value',
- isStatic: false
- },
- value: {
- content: '_ctx.model',
- isStatic: false
- }
- })
-
- expect(props[1]).toMatchObject({
- key: {
- children: [
- '"onUpdate:" + ',
- {
- content: '_ctx.value',
- isStatic: false
- }
- ]
- },
- value: {
- children: [
- '$event => (',
- {
- content: '_ctx.model',
- isStatic: false
- },
- ' = $event)'
- ]
- }
+ expect(props).toMatchObject({
+ type: NodeTypes.JS_CALL_EXPRESSION,
+ callee: NORMALIZE_PROPS,
+ arguments: [
+ {
+ type: NodeTypes.JS_OBJECT_EXPRESSION,
+ properties: [
+ {
+ key: {
+ content: '_ctx.value',
+ isStatic: false
+ },
+ value: {
+ content: '_ctx.model',
+ isStatic: false
+ }
+ },
+ {
+ key: {
+ children: [
+ '"onUpdate:" + ',
+ {
+ content: '_ctx.value',
+ isStatic: false
+ }
+ ]
+ },
+ value: {
+ children: [
+ '$event => (',
+ {
+ content: '_ctx.model',
+ isStatic: false
+ },
+ ' = $event)'
+ ]
+ }
+ }
+ ]
+ }
+ ]
})
expect(generate(root, { mode: 'module' }).code).toMatchSnapshot()
CREATE_SLOTS,
RENDER_LIST,
OPEN_BLOCK,
- CREATE_BLOCK,
FRAGMENT,
- CREATE_VNODE,
WITH_DIRECTIVES
} from './runtimeHelpers'
import { PropsExpression } from './transforms/transformElement'
import { ImportItem, TransformContext } from './transform'
+import { getVNodeBlockHelper, getVNodeHelper } from './utils'
// Vue template is a platform-agnostic superset of HTML (syntax only).
// More namespaces like SVG and MathML are declared by platform specific
directives: DirectiveArguments | undefined
isBlock: boolean
disableTracking: boolean
+ isComponent: boolean
}
// JS Node Types ---------------------------------------------------------------
directives?: VNodeCall['directives'],
isBlock: VNodeCall['isBlock'] = false,
disableTracking: VNodeCall['disableTracking'] = false,
+ isComponent: VNodeCall['isComponent'] = false,
loc = locStub
): VNodeCall {
if (context) {
if (isBlock) {
context.helper(OPEN_BLOCK)
- context.helper(CREATE_BLOCK)
+ context.helper(getVNodeBlockHelper(context.inSSR, isComponent))
} else {
- context.helper(CREATE_VNODE)
+ context.helper(getVNodeHelper(context.inSSR, isComponent))
}
if (directives) {
context.helper(WITH_DIRECTIVES)
directives,
isBlock,
disableTracking,
+ isComponent,
loc
}
}
import {
advancePositionWithMutation,
assert,
+ getVNodeBlockHelper,
+ getVNodeHelper,
isSimpleIdentifier,
toValidAssetId
} from './utils'
POP_SCOPE_ID,
WITH_SCOPE_ID,
WITH_DIRECTIVES,
- CREATE_BLOCK,
+ CREATE_ELEMENT_VNODE,
OPEN_BLOCK,
CREATE_STATIC,
WITH_CTX,
runtimeGlobalName = `Vue`,
runtimeModuleName = `vue`,
ssr = false,
- isTS = false
+ isTS = false,
+ inSSR = false
}: CodegenOptions
): CodegenContext {
const context: CodegenContext = {
runtimeModuleName,
ssr,
isTS,
+ inSSR,
source: ast.loc.source,
code: ``,
column: 1,
} else {
genFunctionPreamble(ast, preambleContext)
}
-
// enter render function
const functionName = ssr ? `ssrRender` : `render`
const args = ssr ? ['_ctx', '_push', '_parent', '_attrs'] : ['_ctx', '_cache']
if (ast.hoists.length) {
const staticHelpers = [
CREATE_VNODE,
+ CREATE_ELEMENT_VNODE,
CREATE_COMMENT,
CREATE_TEXT,
CREATE_STATIC
dynamicProps,
directives,
isBlock,
- disableTracking
+ disableTracking,
+ isComponent
} = node
if (directives) {
push(helper(WITH_DIRECTIVES) + `(`)
if (pure) {
push(PURE_ANNOTATION)
}
- push(helper(isBlock ? CREATE_BLOCK : CREATE_VNODE) + `(`, node)
+ const callHelper: symbol = isBlock
+ ? getVNodeBlockHelper(context.inSSR, isComponent)
+ : getVNodeHelper(context.inSSR, isComponent)
+ push(helper(callHelper) + `(`, node)
genNodeList(
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
context
*/
prefixIdentifiers?: boolean
/**
- * Generate SSR-optimized render functions instead.
+ * Control whether generate SSR-optimized render functions instead.
* The resulting function must be attached to the component via the
* `ssrRender` option instead of `render`.
+ *
+ * When compiler generates code for SSR's fallback branch, we need to set it to false:
+ * - context.ssr = false
+ *
+ * see `subTransform` in `ssrTransformCompoent.ts`
*/
ssr?: boolean
+ /**
+ * Indicates whether the compiler generates code for SSR,
+ * it is always true when generating code for SSR,
+ * regardless of whether we are generating code for SSR's fallback branch,
+ * this means that when the compiler generates code for SSR's fallback branch:
+ * - context.ssr = false
+ * - context.inSSR = true
+ */
+ inSSR?: boolean
/**
* Optional binding metadata analyzed from script - used to optimize
* binding access when `prefixIdentifiers` is enabled.
export const BASE_TRANSITION = Symbol(__DEV__ ? `BaseTransition` : ``)
export const OPEN_BLOCK = Symbol(__DEV__ ? `openBlock` : ``)
export const CREATE_BLOCK = Symbol(__DEV__ ? `createBlock` : ``)
+export const CREATE_ELEMENT_BLOCK = Symbol(__DEV__ ? `createElementBlock` : ``)
export const CREATE_VNODE = Symbol(__DEV__ ? `createVNode` : ``)
+export const CREATE_ELEMENT_VNODE = Symbol(__DEV__ ? `createElementVNode` : ``)
export const CREATE_COMMENT = Symbol(__DEV__ ? `createCommentVNode` : ``)
export const CREATE_TEXT = Symbol(__DEV__ ? `createTextVNode` : ``)
export const CREATE_STATIC = Symbol(__DEV__ ? `createStaticVNode` : ``)
export const CREATE_SLOTS = Symbol(__DEV__ ? `createSlots` : ``)
export const TO_DISPLAY_STRING = Symbol(__DEV__ ? `toDisplayString` : ``)
export const MERGE_PROPS = Symbol(__DEV__ ? `mergeProps` : ``)
+export const NORMALIZE_CLASS = Symbol(__DEV__ ? `normalizeClass` : ``)
+export const NORMALIZE_STYLE = Symbol(__DEV__ ? `normalizeStyle` : ``)
+export const NORMALIZE_PROPS = Symbol(__DEV__ ? `normalizeProps` : ``)
+export const GUARD_REACTIVE_PROPS = Symbol(__DEV__ ? `guardReactiveProps` : ``)
export const TO_HANDLERS = Symbol(__DEV__ ? `toHandlers` : ``)
export const CAMELIZE = Symbol(__DEV__ ? `camelize` : ``)
export const CAPITALIZE = Symbol(__DEV__ ? `capitalize` : ``)
[BASE_TRANSITION]: `BaseTransition`,
[OPEN_BLOCK]: `openBlock`,
[CREATE_BLOCK]: `createBlock`,
+ [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
[CREATE_VNODE]: `createVNode`,
+ [CREATE_ELEMENT_VNODE]: `createElementVNode`,
[CREATE_COMMENT]: `createCommentVNode`,
[CREATE_TEXT]: `createTextVNode`,
[CREATE_STATIC]: `createStaticVNode`,
[CREATE_SLOTS]: `createSlots`,
[TO_DISPLAY_STRING]: `toDisplayString`,
[MERGE_PROPS]: `mergeProps`,
+ [NORMALIZE_CLASS]: `normalizeClass`,
+ [NORMALIZE_STYLE]: `normalizeStyle`,
+ [NORMALIZE_PROPS]: `normalizeProps`,
+ [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
[TO_HANDLERS]: `toHandlers`,
[CAMELIZE]: `camelize`,
[CAPITALIZE]: `capitalize`,
TO_DISPLAY_STRING,
FRAGMENT,
helperNameMap,
- CREATE_BLOCK,
CREATE_COMMENT,
- OPEN_BLOCK,
- CREATE_VNODE
+ OPEN_BLOCK
} from './runtimeHelpers'
-import { isVSlot } from './utils'
+import { getVNodeBlockHelper, getVNodeHelper, isVSlot } from './utils'
import { hoistStatic, isSingleElementRoot } from './transforms/hoistStatic'
import { CompilerCompatOptions } from './compat/compatConfig'
scopeId = null,
slotted = true,
ssr = false,
+ inSSR = false,
ssrCssVars = ``,
bindingMetadata = EMPTY_OBJ,
inline = false,
scopeId,
slotted,
ssr,
+ inSSR,
ssrCssVars,
bindingMetadata,
inline,
const codegenNode = child.codegenNode
if (codegenNode.type === NodeTypes.VNODE_CALL) {
if (!codegenNode.isBlock) {
- removeHelper(CREATE_VNODE)
codegenNode.isBlock = true
+ removeHelper(getVNodeHelper(context.inSSR, codegenNode.isComponent))
helper(OPEN_BLOCK)
- helper(CREATE_BLOCK)
+ helper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent))
}
}
root.codegenNode = codegenNode
patchFlag + (__DEV__ ? ` /* ${patchFlagText} */` : ``),
undefined,
undefined,
- true
+ true,
+ undefined,
+ false /* isComponent */
)
} else {
// no children = noop. codegen will return null.
ComponentNode,
TemplateNode,
VNodeCall,
- ParentNode
+ ParentNode,
+ JSChildNode,
+ CallExpression
} from '../ast'
import { TransformContext } from '../transform'
import { PatchFlags, isString, isSymbol } from '@vue/shared'
-import { isSlotOutlet } from '../utils'
-import { CREATE_BLOCK, CREATE_VNODE, OPEN_BLOCK } from '../runtimeHelpers'
+import { getVNodeBlockHelper, getVNodeHelper, isSlotOutlet } from '../utils'
+import {
+ OPEN_BLOCK,
+ GUARD_REACTIVE_PROPS,
+ NORMALIZE_CLASS,
+ NORMALIZE_PROPS,
+ NORMALIZE_STYLE
+} from '../runtimeHelpers'
export function hoistStatic(root: RootNode, context: TransformContext) {
walk(
// nested updates.
if (codegenNode.isBlock) {
context.removeHelper(OPEN_BLOCK)
- context.removeHelper(CREATE_BLOCK)
+ context.removeHelper(
+ getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
+ )
codegenNode.isBlock = false
- context.helper(CREATE_VNODE)
+ context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent))
}
constantCache.set(node, returnType)
}
}
+const allowHoistedHelperSet = new Set([
+ NORMALIZE_CLASS,
+ NORMALIZE_STYLE,
+ NORMALIZE_PROPS,
+ GUARD_REACTIVE_PROPS
+])
+
+function getConstantTypeOfHelperCall(
+ value: CallExpression,
+ context: TransformContext
+): ConstantTypes {
+ if (
+ value.type === NodeTypes.JS_CALL_EXPRESSION &&
+ !isString(value.callee) &&
+ allowHoistedHelperSet.has(value.callee)
+ ) {
+ const arg = value.arguments[0] as JSChildNode
+ if (arg.type === NodeTypes.SIMPLE_EXPRESSION) {
+ return getConstantType(arg, context)
+ } else if (arg.type === NodeTypes.JS_CALL_EXPRESSION) {
+ // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
+ return getConstantTypeOfHelperCall(arg, context)
+ }
+ }
+ return ConstantTypes.NOT_CONSTANT
+}
+
function getGeneratedPropsConstantType(
node: PlainElementNode,
context: TransformContext
returnType = keyType
}
if (value.type !== NodeTypes.SIMPLE_EXPRESSION) {
+ // some helper calls can be hoisted,
+ // such as the `normalizeProps` generated by the compiler for pre-normalize class,
+ // in this case we need to respect the ConstanType of the helper's argments
+ if (value.type === NodeTypes.JS_CALL_EXPRESSION) {
+ return getConstantTypeOfHelperCall(value, context)
+ }
return ConstantTypes.NOT_CONSTANT
}
const valueType = getConstantType(value, context)
RESOLVE_COMPONENT,
RESOLVE_DYNAMIC_COMPONENT,
MERGE_PROPS,
+ NORMALIZE_CLASS,
+ NORMALIZE_STYLE,
+ NORMALIZE_PROPS,
TO_HANDLERS,
TELEPORT,
KEEP_ALIVE,
SUSPENSE,
- UNREF
+ UNREF,
+ GUARD_REACTIVE_PROPS
} from '../runtimeHelpers'
import {
getInnerRange,
vnodeDirectives,
!!shouldUseBlock,
false /* disableTracking */,
+ isComponent,
node.loc
)
}
// skip if the prop is a cached handler or has constant value
return
}
+
if (name === 'ref') {
hasRef = true
- } else if (name === 'class' && !isComponent) {
+ } else if (name === 'class') {
hasClassBinding = true
- } else if (name === 'style' && !isComponent) {
+ } else if (name === 'style') {
hasStyleBinding = true
} else if (name !== 'key' && !dynamicPropNames.includes(name)) {
dynamicPropNames.push(name)
}
+
+ // treat the dynamic class and style binding of the component as dynamic props
+ if (
+ isComponent &&
+ (name === 'class' || name === 'style') &&
+ !dynamicPropNames.includes(name)
+ ) {
+ dynamicPropNames.push(name)
+ }
} else {
hasDynamicKeys = true
}
if (hasDynamicKeys) {
patchFlag |= PatchFlags.FULL_PROPS
} else {
- if (hasClassBinding) {
+ if (hasClassBinding && !isComponent) {
patchFlag |= PatchFlags.CLASS
}
- if (hasStyleBinding) {
+ if (hasStyleBinding && !isComponent) {
patchFlag |= PatchFlags.STYLE
}
if (dynamicPropNames.length) {
patchFlag |= PatchFlags.NEED_PATCH
}
+ // pre-normalize props, SSR is skipped for now
+ if (!context.inSSR && propsExpression) {
+ switch (propsExpression.type) {
+ case NodeTypes.JS_OBJECT_EXPRESSION:
+ // means that there is no v-bind,
+ // but still need to deal with dynamic key binding
+ let classKeyIndex = -1
+ let styleKeyIndex = -1
+ let dynamicKeyIndex = -1
+
+ for (let i = 0; i < propsExpression.properties.length; i++) {
+ const p = propsExpression.properties[i]
+ if (p.key.type !== NodeTypes.SIMPLE_EXPRESSION) continue
+ if (!isStaticExp(p.key)) dynamicKeyIndex = i
+ if (isStaticExp(p.key) && p.key.content === 'class') classKeyIndex = i
+ if (isStaticExp(p.key) && p.key.content === 'style') styleKeyIndex = i
+ }
+
+ const classProp = propsExpression.properties[classKeyIndex]
+ const styleProp = propsExpression.properties[styleKeyIndex]
+
+ // no dynamic key
+ if (dynamicKeyIndex === -1) {
+ if (classProp && !isStaticExp(classProp.value)) {
+ classProp.value = createCallExpression(
+ context.helper(NORMALIZE_CLASS),
+ [classProp.value]
+ )
+ }
+ if (
+ styleProp &&
+ !isStaticExp(styleProp.value) &&
+ // the static style is compiled into an object,
+ // so use `hasStyleBinding` to ensure that it is a dynamic style binding
+ hasStyleBinding
+ ) {
+ styleProp.value = createCallExpression(
+ context.helper(NORMALIZE_STYLE),
+ [styleProp.value]
+ )
+ }
+ } else {
+ // dynamic key binding, wrap with `normalizeProps`
+ propsExpression = createCallExpression(
+ context.helper(NORMALIZE_PROPS),
+ [propsExpression]
+ )
+ }
+ break
+ case NodeTypes.JS_CALL_EXPRESSION:
+ // mergeProps call, do nothing
+ break
+ default:
+ // single v-bind
+ propsExpression = createCallExpression(
+ context.helper(NORMALIZE_PROPS),
+ [
+ createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
+ propsExpression
+ ])
+ ]
+ )
+ break
+ }
+ }
+
return {
props: propsExpression,
directives: runtimeDirectives,
findProp,
isTemplateNode,
isSlotOutlet,
- injectProp
+ injectProp,
+ getVNodeBlockHelper,
+ getVNodeHelper
} from '../utils'
-import {
- RENDER_LIST,
- OPEN_BLOCK,
- CREATE_BLOCK,
- FRAGMENT,
- CREATE_VNODE
-} from '../runtimeHelpers'
+import { RENDER_LIST, OPEN_BLOCK, FRAGMENT } from '../runtimeHelpers'
import { processExpression } from './transformExpression'
import { validateBrowserExpression } from '../validateExpression'
import { PatchFlags, PatchFlagNames } from '@vue/shared'
: keyProp
? PatchFlags.KEYED_FRAGMENT
: PatchFlags.UNKEYED_FRAGMENT
+
forNode.codegenNode = createVNodeCall(
context,
helper(FRAGMENT),
undefined,
true /* isBlock */,
!isStableFragment /* disableTracking */,
+ false /* isComponent */,
node.loc
) as ForCodegenNode
: ``),
undefined,
undefined,
- true
+ true,
+ undefined,
+ false /* isComponent */
)
} else {
// Normal element v-for. Directly use the child's codegenNode
if (childBlock.isBlock) {
// switch from block to vnode
removeHelper(OPEN_BLOCK)
- removeHelper(CREATE_BLOCK)
+ removeHelper(
+ getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
+ )
} else {
// switch from vnode to block
- removeHelper(CREATE_VNODE)
+ removeHelper(
+ getVNodeHelper(context.inSSR, childBlock.isComponent)
+ )
}
}
childBlock.isBlock = !isStableFragment
if (childBlock.isBlock) {
helper(OPEN_BLOCK)
- helper(CREATE_BLOCK)
+ helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent))
} else {
- helper(CREATE_VNODE)
+ helper(getVNodeHelper(context.inSSR, childBlock.isComponent))
}
}
import { createCompilerError, ErrorCodes } from '../errors'
import { processExpression } from './transformExpression'
import { validateBrowserExpression } from '../validateExpression'
+import { FRAGMENT, CREATE_COMMENT, OPEN_BLOCK } from '../runtimeHelpers'
import {
- CREATE_BLOCK,
- FRAGMENT,
- CREATE_COMMENT,
- OPEN_BLOCK,
- CREATE_VNODE
-} from '../runtimeHelpers'
-import { injectProp, findDir, findProp, isBuiltInType } from '../utils'
+ injectProp,
+ findDir,
+ findProp,
+ isBuiltInType,
+ getVNodeHelper,
+ getVNodeBlockHelper
+} from '../utils'
import { PatchFlags, PatchFlagNames } from '@vue/shared'
export const transformIf = createStructuralDirectiveTransform(
undefined,
true,
false,
+ false /* isComponent */,
branch.loc
)
}
.codegenNode as BlockCodegenNode
// Change createVNode to createBlock.
if (vnodeCall.type === NodeTypes.VNODE_CALL && !vnodeCall.isBlock) {
- removeHelper(CREATE_VNODE)
+ removeHelper(getVNodeHelper(context.inSSR, vnodeCall.isComponent))
vnodeCall.isBlock = true
helper(OPEN_BLOCK)
- helper(CREATE_BLOCK)
+ helper(getVNodeBlockHelper(context.inSSR, vnodeCall.isComponent))
}
// inject branch key
injectProp(vnodeCall, keyProperty, context)
SUSPENSE,
KEEP_ALIVE,
BASE_TRANSITION,
- TO_HANDLERS
+ TO_HANDLERS,
+ NORMALIZE_PROPS,
+ GUARD_REACTIVE_PROPS,
+ CREATE_BLOCK,
+ CREATE_ELEMENT_BLOCK,
+ CREATE_VNODE,
+ CREATE_ELEMENT_VNODE
} from './runtimeHelpers'
import { isString, isObject, hyphenate, extend } from '@vue/shared'
+import { PropsExpression } from './transforms/transformElement'
export const isStaticExp = (p: JSChildNode): p is SimpleExpressionNode =>
p.type === NodeTypes.SIMPLE_EXPRESSION && p.isStatic
return node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.SLOT
}
+export function getVNodeHelper(ssr: boolean, isComponent: boolean) {
+ return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE
+}
+
+export function getVNodeBlockHelper(ssr: boolean, isComponent: boolean) {
+ return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK
+}
+
+const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS])
+
+function getUnnormalizedProps(
+ props: PropsExpression | '{}',
+ callPath: CallExpression[] = []
+): [PropsExpression | '{}', CallExpression[]] {
+ if (
+ props &&
+ !isString(props) &&
+ props.type === NodeTypes.JS_CALL_EXPRESSION
+ ) {
+ const callee = props.callee
+ if (!isString(callee) && propsHelperSet.has(callee)) {
+ return getUnnormalizedProps(
+ props.arguments[0] as PropsExpression,
+ callPath.concat(props)
+ )
+ }
+ }
+ return [props, callPath]
+}
export function injectProp(
node: VNodeCall | RenderSlotCall,
prop: Property,
context: TransformContext
) {
let propsWithInjection: ObjectExpression | CallExpression | undefined
- const props =
+ const originalProps =
node.type === NodeTypes.VNODE_CALL ? node.props : node.arguments[2]
+
+ /**
+ * 1. mergeProps(...)
+ * 2. toHandlers(...)
+ * 3. normalizeProps(...)
+ * 4. normalizeProps(guardReactiveProps(...))
+ *
+ * we need to get the real props before normalization
+ */
+ let props = originalProps
+ let callPath: CallExpression[] = []
+ let parentCall: CallExpression | undefined
+ if (
+ props &&
+ !isString(props) &&
+ props.type === NodeTypes.JS_CALL_EXPRESSION
+ ) {
+ const ret = getUnnormalizedProps(props)
+ props = ret[0]
+ callPath = ret[1]
+ parentCall = callPath[callPath.length - 1]
+ }
+
if (props == null || isString(props)) {
propsWithInjection = createObjectExpression([prop])
} else if (props.type === NodeTypes.JS_CALL_EXPRESSION) {
createObjectExpression([prop]),
props
])
+ // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(props))`,
+ // it will be rewritten as `normalizeProps(mergeProps({ key: 0 }, props))`,
+ // the `guardReactiveProps` will no longer be needed
+ if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
+ parentCall = callPath[callPath.length - 2]
+ }
}
if (node.type === NodeTypes.VNODE_CALL) {
- node.props = propsWithInjection
+ if (parentCall) {
+ parentCall.arguments[0] = propsWithInjection
+ } else {
+ node.props = propsWithInjection
+ }
} else {
- node.arguments[2] = propsWithInjection
+ if (parentCall) {
+ parentCall.arguments[0] = propsWithInjection
+ } else {
+ node.arguments[2] = propsWithInjection
+ }
}
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { toDisplayString: _toDisplayString, createVNode: _createVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, normalizeStyle: _normalizeStyle, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\", {
textContent: _toDisplayString(text)
}, null, 8 /* PROPS */, [\\"textContent\\"]),
- _createVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]),
- _createVNode(\\"div\\", null, \\"test\\"),
- _createVNode(\\"div\\", { style: {\\"color\\":\\"red\\"} }, \\"red\\"),
- _createVNode(\\"div\\", { style: {color: 'green'} }, null, 4 /* STYLE */)
+ _createElementVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]),
+ _createElementVNode(\\"div\\", null, \\"test\\"),
+ _createElementVNode(\\"div\\", { style: {\\"color\\":\\"red\\"} }, \\"red\\"),
+ _createElementVNode(\\"div\\", {
+ style: _normalizeStyle({color: 'green'})
+ }, null, 4 /* STYLE */)
], 64 /* STABLE_FRAGMENT */))
}
}"
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"my-input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"my-input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_vModelText, model]
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelDynamic: _vModelDynamic, mergeProps: _mergeProps, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelDynamic: _vModelDynamic, mergeProps: _mergeProps, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", _mergeProps(obj, {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", _mergeProps(obj, {
\\"onUpdate:modelValue\\": $event => (model = $event)
}), null, 16 /* FULL_PROPS */, [\\"onUpdate:modelValue\\"])), [
[_vModelDynamic, model]
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_directive_bind, val, key],
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_vModelText, model]
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelCheckbox: _vModelCheckbox, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelCheckbox: _vModelCheckbox, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
type: \\"checkbox\\",
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_directive_bind, foo, \\"type\\"],
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelRadio: _vModelRadio, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelRadio: _vModelRadio, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
type: \\"radio\\",
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"input\\", {
type: \\"text\\",
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelSelect: _vModelSelect, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelSelect: _vModelSelect, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"select\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"select\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_vModelSelect, model]
return function render(_ctx, _cache) {
with (_ctx) {
- const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vModelText: _vModelText, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"textarea\\", {
+ return _withDirectives((_openBlock(), _createElementBlock(\\"textarea\\", {
\\"onUpdate:modelValue\\": $event => (model = $event)
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
[_vModelText, model]
return function render(_ctx, _cache) {
with (_ctx) {
- const { vShow: _vShow, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
+ const { vShow: _vShow, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
+ return _withDirectives((_openBlock(), _createElementBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
[_vShow, a]
])
}
return function render(_ctx, _cache) {
with (_ctx) {
- const { openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createVNode: _createVNode, Fragment: _Fragment, Transition: _Transition, withCtx: _withCtx } = _Vue
+ const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createElementVNode: _createElementVNode, Fragment: _Fragment, Transition: _Transition, withCtx: _withCtx, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Transition, null, {
default: _withCtx(() => [
a
- ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"hey\\"))
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"hey\\"))
: b
- ? (_openBlock(), _createBlock(\\"div\\", { key: 1 }, \\"hey\\"))
- : (_openBlock(), _createBlock(\\"div\\", { key: 2 }, [
+ ? (_openBlock(), _createElementBlock(\\"div\\", { key: 1 }, \\"hey\\"))
+ : (_openBlock(), _createElementBlock(\\"div\\", { key: 2 }, [
c
- ? (_openBlock(), _createBlock(\\"p\\", { key: 0 }))
- : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [
+ ? (_openBlock(), _createElementBlock(\\"p\\", { key: 0 }))
+ : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [
_createCommentVNode(\\" this should not be ignored \\"),
- _createVNode(\\"p\\")
+ _createElementVNode(\\"p\\")
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
]))
]),
`;
exports[`SFC compile <script setup> inlineTemplate mode avoid unref() when necessary 1`] = `
-"import { unref as _unref, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { unref as _unref, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import { ref } from 'vue'
import Foo, { bar } from './Foo.vue'
function fn() {}
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
_createVNode(Foo, null, {
default: _withCtx(() => [
_createTextVNode(_toDisplayString(_unref(bar)), 1 /* TEXT */)
]),
_: 1 /* STABLE */
}),
- _createVNode(\\"div\\", { onClick: fn }, _toDisplayString(count.value) + \\" \\" + _toDisplayString(constant) + \\" \\" + _toDisplayString(_unref(maybe)) + \\" \\" + _toDisplayString(_unref(lett)) + \\" \\" + _toDisplayString(_unref(other)), 1 /* TEXT */)
+ _createElementVNode(\\"div\\", { onClick: fn }, _toDisplayString(count.value) + \\" \\" + _toDisplayString(constant) + \\" \\" + _toDisplayString(_unref(maybe)) + \\" \\" + _toDisplayString(_unref(lett)) + \\" \\" + _toDisplayString(_unref(other)), 1 /* TEXT */)
], 64 /* STABLE_FRAGMENT */))
}
}
`;
exports[`SFC compile <script setup> inlineTemplate mode referencing scope components and directives 1`] = `
-"import { unref as _unref, createVNode as _createVNode, withDirectives as _withDirectives, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { unref as _unref, createElementVNode as _createElementVNode, withDirectives as _withDirectives, createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import ChildComp from './Child.vue'
import SomeOtherComp from './Other.vue'
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _withDirectives(_createVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _withDirectives(_createElementVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
[_unref(vMyDir)]
]),
_createVNode(ChildComp),
`;
exports[`SFC compile <script setup> inlineTemplate mode should not wrap render fn with withId when having scoped styles 1`] = `
-"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\"
+"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, withScopeId as _withScopeId } from \\"vue\\"
const _withId = /*#__PURE__*/_withScopeId(\\"data-v-xxxxxxxx\\")
const msg = 1
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(\\"h1\\", null, _toDisplayString(msg)))
+ return (_openBlock(), _createElementBlock(\\"h1\\", null, _toDisplayString(msg)))
}
}
`;
exports[`SFC compile <script setup> inlineTemplate mode should work 1`] = `
-"import { toDisplayString as _toDisplayString, createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
-const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"static\\", -1 /* HOISTED */)
+const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"static\\", -1 /* HOISTED */)
import { ref } from 'vue'
const count = ref(0)
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\", null, _toDisplayString(count.value), 1 /* TEXT */),
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\", null, _toDisplayString(count.value), 1 /* TEXT */),
_hoisted_1
], 64 /* STABLE_FRAGMENT */))
}
`;
exports[`SFC compile <script setup> inlineTemplate mode template assignment expression codegen 1`] = `
-"import { createVNode as _createVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import { ref } from 'vue'
let v = ref(1)
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\", {
onClick: _cache[1] || (_cache[1] = $event => (count.value = 1))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[2] || (_cache[2] = $event => (maybe.value = count.value))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[3] || (_cache[3] = $event => (_isRef(lett) ? lett.value = count.value : lett = count.value))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[4] || (_cache[4] = $event => (_isRef(v) ? v.value += 1 : v += 1))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[5] || (_cache[5] = $event => (_isRef(v) ? v.value -= 1 : v -= 1))
})
], 64 /* STABLE_FRAGMENT */))
`;
exports[`SFC compile <script setup> inlineTemplate mode template destructure assignment codegen 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import { ref } from 'vue'
let lett = 1
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\", {
onClick: _cache[1] || (_cache[1] = $event => (({ count: count.value } = val)))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[2] || (_cache[2] = $event => ([maybe.value] = val))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[3] || (_cache[3] = $event => (({ lett: lett } = val)))
})
], 64 /* STABLE_FRAGMENT */))
`;
exports[`SFC compile <script setup> inlineTemplate mode template update expression codegen 1`] = `
-"import { createVNode as _createVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import { ref } from 'vue'
let lett = 1
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"div\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"div\\", {
onClick: _cache[1] || (_cache[1] = $event => (count.value++))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[2] || (_cache[2] = $event => (--count.value))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[3] || (_cache[3] = $event => (maybe.value++))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[4] || (_cache[4] = $event => (--maybe.value))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[5] || (_cache[5] = $event => (_isRef(lett) ? lett.value++ : lett++))
}),
- _createVNode(\\"div\\", {
+ _createElementVNode(\\"div\\", {
onClick: _cache[6] || (_cache[6] = $event => (_isRef(lett) ? --lett.value : --lett))
})
], 64 /* STABLE_FRAGMENT */))
`;
exports[`SFC compile <script setup> inlineTemplate mode v-model codegen 1`] = `
-"import { vModelText as _vModelText, createVNode as _createVNode, withDirectives as _withDirectives, unref as _unref, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { vModelText as _vModelText, createElementVNode as _createElementVNode, withDirectives as _withDirectives, unref as _unref, isRef as _isRef, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import { ref } from 'vue'
let lett = 1
return (_ctx, _cache) => {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _withDirectives(_createVNode(\\"input\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _withDirectives(_createElementVNode(\\"input\\", {
\\"onUpdate:modelValue\\": _cache[1] || (_cache[1] = $event => (count.value = $event))
}, null, 512 /* NEED_PATCH */), [
[_vModelText, count.value]
]),
- _withDirectives(_createVNode(\\"input\\", {
+ _withDirectives(_createElementVNode(\\"input\\", {
\\"onUpdate:modelValue\\": _cache[2] || (_cache[2] = $event => (_isRef(maybe) ? maybe.value = $event : null))
}, null, 512 /* NEED_PATCH */), [
[_vModelText, _unref(maybe)]
]),
- _withDirectives(_createVNode(\\"input\\", {
+ _withDirectives(_createElementVNode(\\"input\\", {
\\"onUpdate:modelValue\\": _cache[3] || (_cache[3] = $event => (_isRef(lett) ? lett.value = $event : lett = $event))
}, null, 512 /* NEED_PATCH */), [
[_vModelText, _unref(lett)]
exports[`source map 1`] = `
Object {
- "mappings": ";;;wBACE,aAA8B;IAAzB,aAAmB,4BAAbA,WAAM",
+ "mappings": ";;;wBACE,oBAA8B;IAAzB,oBAAmB,4BAAbA,WAAM",
"names": Array [
"render",
],
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler sfc: transform asset url should allow for full base URLs, with paths 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost:3000/src/logo.png\\" }))
+ return (_openBlock(), _createElementBlock(\\"img\\", { src: \\"http://localhost:3000/src/logo.png\\" }))
}"
`;
exports[`compiler sfc: transform asset url should allow for full base URLs, without paths 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost:3000/logo.png\\" }))
+ return (_openBlock(), _createElementBlock(\\"img\\", { src: \\"http://localhost:3000/logo.png\\" }))
}"
`;
exports[`compiler sfc: transform asset url should allow for full base URLs, without port 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"img\\", { src: \\"http://localhost/logo.png\\" }))
+ return (_openBlock(), _createElementBlock(\\"img\\", { src: \\"http://localhost/logo.png\\" }))
}"
`;
exports[`compiler sfc: transform asset url should allow for full base URLs, without protocol 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"img\\", { src: \\"//localhost/logo.png\\" }))
+ return (_openBlock(), _createElementBlock(\\"img\\", { src: \\"//localhost/logo.png\\" }))
}"
`;
exports[`compiler sfc: transform asset url support uri fragment 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from '@svg/file.svg'
const _hoisted_1 = _imports_0 + '#fragment'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"use\\", { href: _hoisted_1 }))
+ return (_openBlock(), _createElementBlock(\\"use\\", { href: _hoisted_1 }))
}"
`;
exports[`compiler sfc: transform asset url support uri is empty 1`] = `
-"import { openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(\\"use\\", { href: '' }))
+ return (_openBlock(), _createElementBlock(\\"use\\", { href: '' }))
}"
`;
exports[`compiler sfc: transform asset url transform assetUrls 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from './logo.png'
import _imports_1 from 'fixtures/logo.png'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", { src: _imports_0 }),
- _createVNode(\\"img\\", { src: _imports_1 }),
- _createVNode(\\"img\\", { src: _imports_1 }),
- _createVNode(\\"img\\", { src: \\"http://example.com/fixtures/logo.png\\" }),
- _createVNode(\\"img\\", { src: \\"/fixtures/logo.png\\" }),
- _createVNode(\\"img\\", { src: \\"data:image/png;base64,i\\" })
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", { src: _imports_0 }),
+ _createElementVNode(\\"img\\", { src: _imports_1 }),
+ _createElementVNode(\\"img\\", { src: _imports_1 }),
+ _createElementVNode(\\"img\\", { src: \\"http://example.com/fixtures/logo.png\\" }),
+ _createElementVNode(\\"img\\", { src: \\"/fixtures/logo.png\\" }),
+ _createElementVNode(\\"img\\", { src: \\"data:image/png;base64,i\\" })
], 64 /* STABLE_FRAGMENT */))
}"
`;
exports[`compiler sfc: transform asset url with explicit base 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from 'bar.png'
import _imports_1 from '@theme/bar.png'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", { src: \\"/foo/bar.png\\" }),
- _createVNode(\\"img\\", { src: \\"bar.png\\" }),
- _createVNode(\\"img\\", { src: _imports_0 }),
- _createVNode(\\"img\\", { src: _imports_1 })
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", { src: \\"/foo/bar.png\\" }),
+ _createElementVNode(\\"img\\", { src: \\"bar.png\\" }),
+ _createElementVNode(\\"img\\", { src: _imports_0 }),
+ _createElementVNode(\\"img\\", { src: _imports_1 })
], 64 /* STABLE_FRAGMENT */))
}"
`;
exports[`compiler sfc: transform asset url with includeAbsolute: true 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from './bar.png'
import _imports_1 from '/bar.png'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", { src: _imports_0 }),
- _createVNode(\\"img\\", { src: _imports_1 }),
- _createVNode(\\"img\\", { src: \\"https://foo.bar/baz.png\\" })
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", { src: _imports_0 }),
+ _createElementVNode(\\"img\\", { src: _imports_1 }),
+ _createElementVNode(\\"img\\", { src: \\"https://foo.bar/baz.png\\" })
], 64 /* STABLE_FRAGMENT */))
}"
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler sfc: transform srcset transform srcset 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from './logo.png'
const _hoisted_8 = \\"/logo.png\\" + ', ' + _imports_0 + ' 2x'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_1
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_2
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_3
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_4
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_5
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_6
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_7
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: \\"/logo.png, /logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"https://example.com/logo.png\\",
srcset: \\"https://example.com/logo.png, https://example.com/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: _hoisted_8
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"data:image/png;base64,i\\",
srcset: \\"data:image/png;base64,i 1x, data:image/png;base64,i 2x\\"
})
`;
exports[`compiler sfc: transform srcset transform srcset w/ base 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png, /foo/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png 2x, /foo/logo.png\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png 2x, /foo/logo.png 3x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png, /foo/logo.png 2x, /foo/logo.png 3x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: \\"/logo.png, /logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"https://example.com/logo.png\\",
srcset: \\"https://example.com/logo.png, https://example.com/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: \\"/logo.png, /foo/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"data:image/png;base64,i\\",
srcset: \\"data:image/png;base64,i 1x, data:image/png;base64,i 2x\\"
})
`;
exports[`compiler sfc: transform srcset transform srcset w/ includeAbsolute: true 1`] = `
-"import { createVNode as _createVNode, Fragment as _Fragment, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\"
+"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
import _imports_0 from './logo.png'
import _imports_1 from '/logo.png'
const _hoisted_9 = _imports_1 + ', ' + _imports_0 + ' 2x'
export function render(_ctx, _cache) {
- return (_openBlock(), _createBlock(_Fragment, null, [
- _createVNode(\\"img\\", {
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_1
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_2
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_3
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_4
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_5
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_6
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_7
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: _hoisted_8
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"https://example.com/logo.png\\",
srcset: \\"https://example.com/logo.png, https://example.com/logo.png 2x\\"
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"/logo.png\\",
srcset: _hoisted_9
}),
- _createVNode(\\"img\\", {
+ _createElementVNode(\\"img\\", {
src: \\"data:image/png;base64,i\\",
srcset: \\"data:image/png;base64,i 1x, data:image/png;base64,i 2x\\"
})
// apply DOM-specific parsing options
...parserOptions,
ssr: true,
+ inSSR: true,
scopeId: options.mode === 'function' ? null : options.scopeId,
// always prefix since compiler-ssr doesn't have size concern
prefixIdentifiers: true,
): ReturnStatement {
// apply a sub-transform using vnode-based transforms.
const rawOptions = rawOptionsMap.get(parentContext.root)!
+
const subOptions = {
...rawOptions,
// overwrite with vnode-based transforms
setBlockTracking,
createTextVNode,
createCommentVNode,
- createStaticVNode
+ createStaticVNode,
+ createElementVNode,
+ createElementBlock,
+ guardReactiveProps
} from './vnode'
export {
toDisplayString,
camelize,
capitalize,
- toHandlerKey
+ toHandlerKey,
+ normalizeProps,
+ normalizeClass,
+ normalizeStyle
} from '@vue/shared'
// For test-utils
isBlockTreeEnabled += value
}
+function setupBlock(vnode: VNode) {
+ // save current block children on the block vnode
+ vnode.dynamicChildren =
+ isBlockTreeEnabled > 0 ? currentBlock || (EMPTY_ARR as any) : null
+ // close block
+ closeBlock()
+ // a block is always going to be patched, so track it as a child of its
+ // parent block
+ if (isBlockTreeEnabled > 0 && currentBlock) {
+ currentBlock.push(vnode)
+ }
+ return vnode
+}
+
+/**
+ * @private
+ */
+export function createElementBlock(
+ type: string,
+ props?: Record<string, any> | null,
+ children?: any,
+ patchFlag?: number,
+ dynamicProps?: string[],
+ shapeFlag?: number
+) {
+ return setupBlock(
+ createBaseVNode(
+ type,
+ props,
+ children,
+ patchFlag,
+ dynamicProps,
+ shapeFlag,
+ true /* isBlock */
+ )
+ )
+}
+
/**
* Create a block root vnode. Takes the same exact arguments as `createVNode`.
* A block root keeps track of dynamic nodes within the block in the
patchFlag?: number,
dynamicProps?: string[]
): VNode {
- const vnode = createVNode(
- type,
- props,
- children,
- patchFlag,
- dynamicProps,
- true /* isBlock: prevent a block from tracking itself */
+ return setupBlock(
+ createVNode(
+ type,
+ props,
+ children,
+ patchFlag,
+ dynamicProps,
+ true /* isBlock: prevent a block from tracking itself */
+ )
)
- // save current block children on the block vnode
- vnode.dynamicChildren =
- isBlockTreeEnabled > 0 ? currentBlock || (EMPTY_ARR as any) : null
- // close block
- closeBlock()
- // a block is always going to be patched, so track it as a child of its
- // parent block
- if (isBlockTreeEnabled > 0 && currentBlock) {
- currentBlock.push(vnode)
- }
- return vnode
}
export function isVNode(value: any): value is VNode {
: null) as any
}
+function createBaseVNode(
+ type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
+ props: (Data & VNodeProps) | null = null,
+ children: unknown = null,
+ patchFlag = 0,
+ dynamicProps: string[] | null = null,
+ shapeFlag = ShapeFlags.ELEMENT,
+ isBlockNode = false,
+ needFullChildrenNormalization = false
+) {
+ const vnode = {
+ __v_isVNode: true,
+ __v_skip: true,
+ type,
+ props,
+ key: props && normalizeKey(props),
+ ref: props && normalizeRef(props),
+ scopeId: currentScopeId,
+ slotScopeIds: null,
+ children,
+ component: null,
+ suspense: null,
+ ssContent: null,
+ ssFallback: null,
+ dirs: null,
+ transition: null,
+ el: null,
+ anchor: null,
+ target: null,
+ targetAnchor: null,
+ staticCount: 0,
+ shapeFlag,
+ patchFlag,
+ dynamicProps,
+ dynamicChildren: null,
+ appContext: null
+ } as VNode
+
+ if (needFullChildrenNormalization) {
+ normalizeChildren(vnode, children)
+ // normalize suspense children
+ if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) {
+ ;(type as typeof SuspenseImpl).normalize(vnode)
+ }
+ } else if (children) {
+ // compiled element vnode - if children is passed, only possible types are
+ // string or Array.
+ vnode.shapeFlag |= isString(children)
+ ? ShapeFlags.TEXT_CHILDREN
+ : ShapeFlags.ARRAY_CHILDREN
+ }
+
+ // validate key
+ if (__DEV__ && vnode.key !== vnode.key) {
+ warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
+ }
+
+ // track vnode for block tree
+ if (
+ isBlockTreeEnabled > 0 &&
+ // avoid a block node from tracking itself
+ !isBlockNode &&
+ // has current parent block
+ currentBlock &&
+ // presence of a patch flag indicates this node needs patching on updates.
+ // component nodes also should always be patched, because even if the
+ // component doesn't need to update, it needs to persist the instance on to
+ // the next vnode so that it can be properly unmounted later.
+ (vnode.patchFlag > 0 || shapeFlag & ShapeFlags.COMPONENT) &&
+ // the EVENTS flag is only for hydration and if it is the only flag, the
+ // vnode should not be considered dynamic due to handler caching.
+ vnode.patchFlag !== PatchFlags.HYDRATE_EVENTS
+ ) {
+ currentBlock.push(vnode)
+ }
+
+ if (__COMPAT__) {
+ convertLegacyVModelProps(vnode)
+ convertLegacyRefInFor(vnode)
+ defineLegacyVNodeProperties(vnode)
+ }
+
+ return vnode
+}
+
+export { createBaseVNode as createElementVNode }
+
export const createVNode = (__DEV__
? createVNodeWithArgsTransform
: _createVNode) as typeof _createVNode
// class & style normalization.
if (props) {
// for reactive or proxy objects, we need to clone it to enable mutation.
- if (isProxy(props) || InternalObjectKey in props) {
- props = extend({}, props)
- }
+ props = guardReactiveProps(props)!
let { class: klass, style } = props
if (klass && !isString(klass)) {
props.class = normalizeClass(klass)
)
}
- const vnode: VNode = {
- __v_isVNode: true,
- __v_skip: true,
+ return createBaseVNode(
type,
props,
- key: props && normalizeKey(props),
- ref: props && normalizeRef(props),
- scopeId: currentScopeId,
- slotScopeIds: null,
- children: null,
- component: null,
- suspense: null,
- ssContent: null,
- ssFallback: null,
- dirs: null,
- transition: null,
- el: null,
- anchor: null,
- target: null,
- targetAnchor: null,
- shapeFlag,
+ children,
patchFlag,
dynamicProps,
- dynamicChildren: null,
- appContext: null
- }
-
- // validate key
- if (__DEV__ && vnode.key !== vnode.key) {
- warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
- }
-
- normalizeChildren(vnode, children)
-
- // normalize suspense children
- if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) {
- ;(type as typeof SuspenseImpl).normalize(vnode)
- }
-
- if (
- isBlockTreeEnabled > 0 &&
- // avoid a block node from tracking itself
- !isBlockNode &&
- // has current parent block
- currentBlock &&
- // presence of a patch flag indicates this node needs patching on updates.
- // component nodes also should always be patched, because even if the
- // component doesn't need to update, it needs to persist the instance on to
- // the next vnode so that it can be properly unmounted later.
- (patchFlag > 0 || shapeFlag & ShapeFlags.COMPONENT) &&
- // the EVENTS flag is only for hydration and if it is the only flag, the
- // vnode should not be considered dynamic due to handler caching.
- patchFlag !== PatchFlags.HYDRATE_EVENTS
- ) {
- currentBlock.push(vnode)
- }
-
- if (__COMPAT__) {
- convertLegacyVModelProps(vnode)
- convertLegacyRefInFor(vnode)
- defineLegacyVNodeProperties(vnode)
- }
+ shapeFlag,
+ isBlockNode,
+ true
+ )
+}
- return vnode
+export function guardReactiveProps(props: (Data & VNodeProps) | null) {
+ if (!props) return null
+ return isProxy(props) || InternalObjectKey in props
+ ? extend({}, props)
+ : props
}
export function cloneVNode<T, U>(
}
return res.trim()
}
+
+export function normalizeProps(props: Record<string, any> | null) {
+ if (!props) return null
+ let { class: klass, style } = props
+ if (klass && !isString(klass)) {
+ props.class = normalizeClass(klass)
+ }
+ if (style) {
+ props.style = normalizeStyle(style)
+ }
+ return props
+}