diff --git a/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap index d70c5b3b..68990ecc 100644 --- a/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap @@ -3,7 +3,7 @@ exports[`compiler: codegen ArrayExpression 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return [ foo, bar(baz) @@ -34,7 +34,7 @@ export function render(_ctx, _cache) { exports[`compiler: codegen ConditionalExpression 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return ok ? foo() : orNot @@ -47,7 +47,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen Element (callExpression + objectExpression + TemplateChildNode[]) 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return _createVNode(\\"div\\", { id: \\"foo\\", [prop]: bar, @@ -62,7 +62,7 @@ return function render(_ctx, _cache) { 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\\") @@ -78,7 +78,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen comment 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return _createCommentVNode(\\"foo\\") } }" @@ -87,7 +87,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen compound expression 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return _ctx.foo + _toDisplayString(bar) + nested } }" @@ -96,7 +96,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen forNode 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return (_openBlock(true), _createBlock(_Fragment, null, _renderList(), 1)) } }" @@ -106,7 +106,7 @@ exports[`compiler: codegen function mode preamble 1`] = ` "const _Vue = Vue return function render(_ctx, _cache) { - with (this) { + with (_ctx) { const { createVNode: _createVNode, resolveDirective: _resolveDirective } = _Vue return null @@ -128,7 +128,7 @@ const _hoisted_1 = hello const _hoisted_2 = { id: \\"foo\\" } return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return null } }" @@ -137,7 +137,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen ifNode 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return foo ? bar : baz @@ -148,7 +148,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen interpolation 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return _toDisplayString(hello) } }" @@ -176,7 +176,7 @@ export function render(_ctx, _cache) { exports[`compiler: codegen static text 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return \\"hello\\" } }" @@ -185,7 +185,7 @@ return function render(_ctx, _cache) { exports[`compiler: codegen temps 1`] = ` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { let _temp0, _temp1, _temp2 return null diff --git a/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap index 77a37d3a..7eeb4790 100644 --- a/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap @@ -4,7 +4,7 @@ exports[`compiler: integration tests function mode 1`] = ` "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\\", { diff --git a/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap index 47e28dc2..6f69b200 100644 --- a/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap @@ -5,8 +5,8 @@ exports[`scopeId compiler support should push scopeId for hoisted nodes 1`] = ` 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) { @@ -58,7 +58,7 @@ export const render = _withId(function render(_ctx, _cache) { ]) } }) - ]), 512 /* DYNAMIC_SLOTS */)) + ]), 1024 /* DYNAMIC_SLOTS */)) })" `; diff --git a/packages/compiler-core/__tests__/codegen.spec.ts b/packages/compiler-core/__tests__/codegen.spec.ts index 929588f4..f9ebdc09 100644 --- a/packages/compiler-core/__tests__/codegen.spec.ts +++ b/packages/compiler-core/__tests__/codegen.spec.ts @@ -589,7 +589,7 @@ describe('compiler: codegen', () => { expect(code).toMatchInlineSnapshot(` " return function render(_ctx, _cache) { - with (this) { + with (_ctx) { return foo = bar } }" @@ -602,7 +602,7 @@ describe('compiler: codegen', () => { createRoot({ codegenNode: node }) - ).code.match(/with \(this\) \{\s+([^]+)\s+\}\s+\}$/)![1] + ).code.match(/with \(_ctx\) \{\s+([^]+)\s+\}\s+\}$/)![1] } const mockProps = createObjectExpression([ diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap index 5912db0a..0d0ddd8c 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap @@ -4,10 +4,10 @@ exports[`compiler: hoistStatic transform hoist element with static key 1`] = ` "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, [ @@ -24,10 +24,10 @@ const { createVNode: _createVNode } = _Vue 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, [ @@ -43,10 +43,10 @@ const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _ 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, [ @@ -60,11 +60,11 @@ exports[`compiler: hoistStatic transform hoist siblings with common non-hoistabl "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, [ @@ -79,10 +79,10 @@ exports[`compiler: hoistStatic transform hoist simple element 1`] = ` "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, [ @@ -99,13 +99,13 @@ const { createVNode: _createVNode } = _Vue 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] ]) ])) @@ -120,7 +120,7 @@ const { createVNode: _createVNode } = _Vue 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, [ @@ -137,7 +137,7 @@ const { createVNode: _createVNode } = _Vue 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\\") @@ -158,7 +158,7 @@ const { createVNode: _createVNode } = _Vue 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, [ @@ -172,10 +172,10 @@ exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static t "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, [ @@ -189,10 +189,10 @@ exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static t "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, [ @@ -220,7 +220,7 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist expr "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, [ @@ -238,7 +238,7 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist expr "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\\") @@ -257,7 +257,7 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist expr "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, [ @@ -275,7 +275,7 @@ exports[`compiler: hoistStatic transform should NOT hoist components 1`] = ` "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\\") @@ -291,7 +291,7 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic k "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, [ @@ -305,7 +305,7 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic p "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, [ @@ -319,11 +319,11 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic r "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 */) ])) } }" @@ -333,7 +333,7 @@ exports[`compiler: hoistStatic transform should NOT hoist root node 1`] = ` "const _Vue = Vue return function render(_ctx, _cache) { - with (this) { + with (_ctx) { const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue return (_openBlock(), _createBlock(\\"div\\")) @@ -346,10 +346,10 @@ exports[`compiler: hoistStatic transform should hoist v-for children if static 1 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, [ @@ -371,10 +371,10 @@ const _hoisted_1 = { 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, [ diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap index ebf472ad..b626c6e9 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap @@ -4,7 +4,7 @@ exports[`compiler: transform text