exports[`compiler: codegen ArrayExpression 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return [
foo,
bar(baz)
exports[`compiler: codegen ConditionalExpression 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return ok
? foo()
: orNot
exports[`compiler: codegen Element (callExpression + objectExpression + TemplateChildNode[]) 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return _createVNode(\\"div\\", {
id: \\"foo\\",
[prop]: bar,
exports[`compiler: codegen assets + temps 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const _component_Foo = _resolveComponent(\\"Foo\\")
const _component_bar_baz = _resolveComponent(\\"bar-baz\\")
const _component_barbaz = _resolveComponent(\\"barbaz\\")
exports[`compiler: codegen comment 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return _createCommentVNode(\\"foo\\")
}
}"
exports[`compiler: codegen compound expression 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return _ctx.foo + _toDisplayString(bar) + nested
}
}"
exports[`compiler: codegen forNode 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(), 1))
}
}"
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, resolveDirective: _resolveDirective } = _Vue
return null
const _hoisted_2 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return null
}
}"
exports[`compiler: codegen ifNode 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return foo
? bar
: baz
exports[`compiler: codegen interpolation 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return _toDisplayString(hello)
}
}"
exports[`compiler: codegen static text 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return \\"hello\\"
}
}"
exports[`compiler: codegen temps 1`] = `
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
let _temp0, _temp1, _temp2
return null
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment, renderList: _renderList, createTextVNode: _createTextVNode } = _Vue
return (_openBlock(), _createBlock(\\"div\\", {
const _withId = _withScopeId(\\"test\\")
_pushScopeId(\\"test\\")
-const _hoisted_1 = _createVNode(\\"div\\", null, \\"hello\\", -2 /* HOISTED */)
-const _hoisted_2 = _createVNode(\\"div\\", null, \\"world\\", -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */)
+const _hoisted_2 = _createVNode(\\"div\\", null, \\"world\\", -1 /* HOISTED */)
_popScopeId()
export const render = _withId(function render(_ctx, _cache) {
])
}
})
- ]), 512 /* DYNAMIC_SLOTS */))
+ ]), 1024 /* DYNAMIC_SLOTS */))
})"
`;
expect(code).toMatchInlineSnapshot(`
"
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
return foo = bar
}
}"
createRoot({
codegenNode: node
})
- ).code.match(/with \(this\) \{\s+([^]+)\s+\}\s+\}$/)![1]
+ ).code.match(/with \(_ctx\) \{\s+([^]+)\s+\}\s+\}$/)![1]
}
const mockProps = createObjectExpression([
"const _Vue = Vue
const { createVNode: _createVNode } = _Vue
-const _hoisted_1 = _createVNode(\\"div\\", { key: \\"foo\\" }, null, -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
const _hoisted_1 = _createVNode(\\"p\\", null, [
_createVNode(\\"span\\"),
_createVNode(\\"span\\")
-], -2 /* HOISTED */)
+], -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
const _hoisted_1 = _createVNode(\\"div\\", null, [
_createCommentVNode(\\"comment\\")
-], -2 /* HOISTED */)
+], -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createCommentVNode: _createCommentVNode, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
const { createVNode: _createVNode } = _Vue
-const _hoisted_1 = _createVNode(\\"span\\", null, null, -2 /* HOISTED */)
-const _hoisted_2 = _createVNode(\\"div\\", null, null, -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"span\\", null, null, -1 /* HOISTED */)
+const _hoisted_2 = _createVNode(\\"div\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
const { createVNode: _createVNode } = _Vue
-const _hoisted_1 = _createVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _directive_foo = _resolveDirective(\\"foo\\")
return (_openBlock(), _createBlock(\\"div\\", null, [
- _withDirectives(_createVNode(\\"div\\", _hoisted_1, null, -1 /* NEED_PATCH */), [
+ _withDirectives(_createVNode(\\"div\\", _hoisted_1, null, 512 /* NEED_PATCH */), [
[_directive_foo]
])
]))
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
const _hoisted_1 = { id: \\"foo\\" }
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
const _hoisted_1 = { class: { foo: true } }
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
const { createVNode: _createVNode } = _Vue
-const _hoisted_1 = _createVNode(\\"span\\", null, \\"foo \\" + _toDisplayString(1) + \\" \\" + _toDisplayString(true), -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"span\\", null, \\"foo \\" + _toDisplayString(1) + \\" \\" + _toDisplayString(true), -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
const { createVNode: _createVNode } = _Vue
-const _hoisted_1 = _createVNode(\\"span\\", { foo: 0 }, _toDisplayString(1), -2 /* HOISTED */)
+const _hoisted_1 = _createVNode(\\"span\\", { foo: 0 }, _toDisplayString(1), -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
- _createVNode(\\"div\\", { ref: foo }, null, -1 /* NEED_PATCH */)
+ _createVNode(\\"div\\", { ref: foo }, null, 512 /* NEED_PATCH */)
]))
}
}"
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\"))
const { createVNode: _createVNode } = _Vue
const _hoisted_1 = { id: \\"foo\\" }
-const _hoisted_2 = _createVNode(\\"span\\", null, null, -2 /* HOISTED */)
+const _hoisted_2 = _createVNode(\\"span\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
key: 0,
id: \\"foo\\"
}
-const _hoisted_2 = _createVNode(\\"span\\", null, null, -2 /* HOISTED */)
+const _hoisted_2 = _createVNode(\\"span\\", null, null, -1 /* HOISTED */)
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createTextVNode: _createTextVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString } = _Vue
return _toDisplayString(foo) + \\" bar \\" + _toDisplayString(baz)
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Fragment, null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Fragment, null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { toDisplayString: _toDisplayString } = _Vue
return _toDisplayString(foo)
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Fragment, null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, __, index) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, __, index) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (_, key, index) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, renderSlot: _renderSlot } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives } = _Vue
const _directive_foo = _resolveDirective(\\"foo\\")
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => {
- return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, -1 /* NEED_PATCH */)), [
+ return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
[_directive_foo]
])
}), 256 /* UNKEYED_FRAGMENT */))
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue
return (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item, key, index) => {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Fragment: _Fragment } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue
return ok
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"input\\", {
value: model,
\\"onUpdate:value\\": $event => (model = $event)
- }, null, 8 /* PROPS */, [\\"value\\", \\"onUpdate:value\\"]))
+ }, null, 40 /* PROPS, HYDRATE_EVENTS */, [\\"value\\", \\"onUpdate:value\\"]))
}
}"
`;
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { setBlockTracking: _setBlockTracking, createVNode: _createVNode } = _Vue
return _cache[1] || (
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { setBlockTracking: _setBlockTracking, resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { setBlockTracking: _setBlockTracking, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { setBlockTracking: _setBlockTracking, renderSlot: _renderSlot, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { setBlockTracking: _setBlockTracking, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(\\"div\\", null, [
[_ctx.one]: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
[_ctx.two]: ({ bar }) => [_toDisplayString(_ctx.foo), _toDisplayString(bar)],
_: 1
- }, 512 /* DYNAMIC_SLOTS */))
+ }, 1024 /* DYNAMIC_SLOTS */))
}"
`;
fn: () => [_toDisplayString(name)]
}
})
- ]), 512 /* DYNAMIC_SLOTS */))
+ ]), 1024 /* DYNAMIC_SLOTS */))
}"
`;
fn: (props) => [_toDisplayString(props)]
}
: undefined
- ]), 512 /* DYNAMIC_SLOTS */))
+ ]), 1024 /* DYNAMIC_SLOTS */))
}"
`;
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { resolveComponent: _resolveComponent, createSlots: _createSlots, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
name: \\"one\\",
fn: () => [\\"baz\\"]
}
- ]), 512 /* DYNAMIC_SLOTS */))
+ ]), 1024 /* DYNAMIC_SLOTS */))
}
}"
`;
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { resolveComponent: _resolveComponent, createSlots: _createSlots, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
fn: () => [\\"hello\\"]
}
: undefined
- ]), 512 /* DYNAMIC_SLOTS */))
+ ]), 1024 /* DYNAMIC_SLOTS */))
}
}"
`;
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, resolveComponent: _resolveComponent, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _component_Comp = _resolveComponent(\\"Comp\\")
_createVNode(_component_Inner, null, {
default: ({ bar }) => [_toDisplayString(foo), _toDisplayString(bar), _toDisplayString(_ctx.baz)],
_: 1
- }, 512 /* DYNAMIC_SLOTS */),
+ }, 1024 /* DYNAMIC_SLOTS */),
\\" \\",
_toDisplayString(foo),
_toDisplayString(_ctx.bar),
const { node } = parseWithBind(`<div v-foo />`)
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))
})
+
+ test('HYDRATE_EVENTS', () => {
+ // ignore click events (has dedicated fast path)
+ const { node } = parseWithElementTransform(`<div @click="foo" />`, {
+ directiveTransforms: {
+ on: transformOn
+ }
+ })
+ // should only have props flag
+ expect(node.patchFlag).toBe(genFlagText(PatchFlags.PROPS))
+
+ const { node: node2 } = parseWithElementTransform(
+ `<div @keyup="foo" />`,
+ {
+ directiveTransforms: {
+ on: transformOn
+ }
+ }
+ )
+ expect(node2.patchFlag).toBe(
+ genFlagText([PatchFlags.PROPS, PatchFlags.HYDRATE_EVENTS])
+ )
+ })
})
describe('dynamic component', () => {
indent()
if (useWithBlock) {
- push(`with (this) {`)
+ push(`with (_ctx) {`)
indent()
// function mode const declarations should be inside with block
// also they should be renamed to avoid collision with user properties
const analyzePatchFlag = ({ key, value }: Property) => {
if (key.type === NodeTypes.SIMPLE_EXPRESSION && key.isStatic) {
const name = key.content
- if (!isComponent && isOn(name) && name.toLowerCase() !== 'onclick') {
- // This flag is for hydrating event handlers only. We omit the flag for
- // click handlers becaues hydration gives click dedicated fast path.
+ if (
+ !isComponent &&
+ isOn(name) &&
+ // omit the flag for click handlers becaues hydration gives click
+ // dedicated fast path.
+ name.toLowerCase() !== 'onclick' &&
+ // omit v-model handlers
+ name !== 'onUpdate:modelValue'
+ ) {
hasHydrationEventBinding = true
}
if (
hasClassBinding = true
} else if (name === 'style') {
hasStyleBinding = true
- } else if (name !== 'key') {
+ } else if (name !== 'key' && !dynamicPropNames.includes(name)) {
dynamicPropNames.push(name)
}
} else {
patchFlag |= PatchFlags.HYDRATE_EVENTS
}
}
- if (patchFlag === 0 && (hasRef || runtimeDirectives.length > 0)) {
- patchFlag = PatchFlags.NEED_PATCH
+ if (
+ (patchFlag === 0 || patchFlag === PatchFlags.HYDRATE_EVENTS) &&
+ (hasRef || runtimeDirectives.length > 0)
+ ) {
+ patchFlag |= PatchFlags.NEED_PATCH
}
return {
const _hoisted_1 = {}
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { createVNode: _createVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Fragment, null, [
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelDynamic: _vModelDynamic, mergeProps: _mergeProps, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", _mergeProps(obj, {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelCheckbox: _vModelCheckbox, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelRadio: _vModelRadio, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelSelect: _vModelSelect, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"select\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"textarea\\", {
"const _Vue = Vue
return function render(_ctx, _cache) {
- with (this) {
+ with (_ctx) {
const { vShow: _vShow, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
- return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, -1 /* NEED_PATCH */)), [
+ return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
[_vShow, a]
])
}
import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../../src/runtimeHelpers'
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
import { transformExpression } from '../../../compiler-core/src/transforms/transformExpression'
-import { createObjectMatcher } from '../../../compiler-core/__tests__/testUtils'
+import {
+ createObjectMatcher,
+ genFlagText
+} from '../../../compiler-core/__tests__/testUtils'
+import { PatchFlags } from '@vue/shared'
function parseWithVOn(template: string, options: CompilerOptions = {}) {
const ast = parse(template)
cacheHandlers: true
})
expect(root.cached).toBe(1)
- // should not treat cached handler as dynamicProp, so no flags
- expect((root as any).children[0].codegenNode.patchFlag).toBeUndefined()
+ // should not treat cached handler as dynamicProp, so it should have no
+ // dynamicProps flags and only the hydration flag
+ expect((root as any).children[0].codegenNode.patchFlag).toBe(
+ genFlagText(PatchFlags.HYDRATE_EVENTS)
+ )
expect(prop.value).toMatchObject({
type: NodeTypes.JS_CACHE_EXPRESSION,
index: 1,
} from '@vue/runtime-core'
import { mergeProps, normalizeVNode } from '../src/vnode'
import { Data } from '../src/component'
+import { PatchFlags } from '@vue/shared'
describe('vnode', () => {
test('create with just tag', () => {
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
- (vnode1 = createVNode('div', null, 'text', 1 /* TEXT */))
+ (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
+ test('should not track vnodes with only HYDRATE_EVENTS flag', () => {
+ const hoist = createVNode('div')
+ const vnode = (openBlock(),
+ createBlock('div', null, [
+ hoist,
+ createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
+ ]))
+ expect(vnode.dynamicChildren).toStrictEqual([])
+ })
+
test('many times call openBlock', () => {
const hoist = createVNode('div')
let vnode1, vnode2, vnode3
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
- (vnode1 = createVNode('div', null, 'text', 1 /* TEXT */)),
+ (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
(vnode2 = (openBlock(),
createBlock('div', null, [
hoist,
- (vnode3 = createVNode('div', null, 'text', 1 /* TEXT */))
+ (vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
}
try {
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
+ // withProxy is a proxy with a diffrent `has` trap only for
+ // runtime-compiled render functions using `with` block.
+ const proxyToUse = withProxy || proxy
result = normalizeVNode(
- instance.render!.call(withProxy || proxy, proxy, renderCache)
+ instance.render!.call(proxyToUse, proxyToUse, renderCache)
)
} else {
// functional
shouldTrack > 0 &&
currentBlock !== null &&
// the EVENTS flag is only for hydration and if it is the only flag, the
- // vnode should not be considered dynamic.
+ // vnode should not be considered dynamic due to handler caching.
patchFlag !== PatchFlags.HYDRATE_EVENTS &&
(patchFlag > 0 ||
- patchFlag === PatchFlags.NEED_PATCH ||
shapeFlag & ShapeFlags.SUSPENSE ||
shapeFlag & ShapeFlags.STATEFUL_COMPONENT ||
shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT)
// Indicates a fragment with unkeyed children.
UNKEYED_FRAGMENT = 1 << 8,
+ // Indicates an element that only needs non-props patching, e.g. ref or
+ // directives (onVnodeXXX hooks). since every patched vnode checks for refs
+ // and onVnodeXXX hooks, itt simply marks the vnode so that a parent block
+ // will track it.
+ NEED_PATCH = 1 << 9,
+
// Indicates a component with dynamic slots (e.g. slot that references a v-for
// iterated value, or dynamic slot names).
// Components with this flag are always force updated.
- DYNAMIC_SLOTS = 1 << 9,
+ DYNAMIC_SLOTS = 1 << 10,
// SPECIAL FLAGS -------------------------------------------------------------
// patchFlag > 0), and are mutually exclusive. When checking for a speical
// flag, simply check patchFlag === FLAG.
- // Indicates an element that only needs non-props patching, e.g. ref or
- // directives (onVnodeXXX hooks). since every patched vnode checks for refs
- // and onVnodeXXX hooks, itt simply marks the vnode so that a parent block
- // will track it.
- NEED_PATCH = -1,
-
// Indicates a hoisted static vnode. This is a hint for hydration to skip
// the entire sub tree since static content never needs to be updated.
- HOISTED = -2,
+ HOISTED = -1,
// A special flag that indicates that the diffing algorithm should bail out
// of optimized mode. This is only on block fragments created by renderSlot()
// when encountering non-compiler generated slots (i.e. manually written
// render functions, which should always be fully diffed)
- BAIL = -3
+ BAIL = -2
}
// runtime object for public consumption