forked from vuejs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
655 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 205 additions & 0 deletions
205
packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`compiler: hositStatic transform hoist nested static tree 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = _createVNode(\\"p\\", null, [ | ||
_createVNode(\\"span\\"), | ||
_createVNode(\\"span\\") | ||
]) | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_hoisted_1 | ||
])) | ||
} | ||
}" | ||
`; | ||
|
||
exports[`compiler: hositStatic transform hoist siblings with common non-hoistable parent 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = _createVNode(\\"span\\") | ||
const _hoisted_2 = _createVNode(\\"div\\") | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_hoisted_1, | ||
_hoisted_2 | ||
])) | ||
} | ||
}" | ||
`; | ||
|
||
exports[`compiler: hositStatic transform hoist simple element 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = _createVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\") | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_hoisted_1 | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform hoist static props for elements with directives 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = { id: \\"foo\\" } | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, applyDirectives: _applyDirectives, resolveDirective: _resolveDirective, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
const _directive_foo = _resolveDirective(\\"foo\\") | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_applyDirectives(_createVNode(\\"div\\", _hoisted_1, null, 32 /* NEED_PATCH */), [ | ||
[_directive_foo] | ||
]) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform hoist static props for elements with dynamic text children 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = { id: \\"foo\\" } | ||
return function render() { | ||
with (this) { | ||
const { toString: _toString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_createVNode(\\"div\\", _hoisted_1, _toString(hello), 1 /* TEXT */) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform hoist static props for elements with unhoistable children 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = { id: \\"foo\\" } | ||
return function render() { | ||
with (this) { | ||
const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
const _component_Comp = _resolveComponent(\\"Comp\\") | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_createVNode(\\"div\\", _hoisted_1, [ | ||
_createVNode(_component_Comp) | ||
]) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform should NOT hoist components 1`] = ` | ||
"const _Vue = Vue | ||
return function render() { | ||
with (this) { | ||
const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
const _component_Comp = _resolveComponent(\\"Comp\\") | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_createVNode(_component_Comp) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform should NOT hoist element with dynamic props 1`] = ` | ||
"const _Vue = Vue | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
_createVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform should NOT hoist root node 1`] = ` | ||
"const _Vue = Vue | ||
return function render() { | ||
with (this) { | ||
const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\")) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform should hoist v-for children if static 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = { id: \\"foo\\" } | ||
const _hoisted_2 = _createVNode(\\"span\\") | ||
return function render() { | ||
with (this) { | ||
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
(_openBlock(), _createBlock(_Fragment, null, _renderList(list, (i) => { | ||
return (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [ | ||
_hoisted_2 | ||
])) | ||
}), 128 /* UNKEYED_FRAGMENT */)) | ||
])) | ||
} | ||
}" | ||
`; | ||
exports[`compiler: hositStatic transform should hoist v-if props/children if static 1`] = ` | ||
"const _Vue = Vue | ||
const _createVNode = Vue.createVNode | ||
const _hoisted_1 = { | ||
key: 0, | ||
id: \\"foo\\" | ||
} | ||
const _hoisted_2 = _createVNode(\\"span\\") | ||
return function render() { | ||
with (this) { | ||
const { openBlock: _openBlock, createVNode: _createVNode, createBlock: _createBlock, Empty: _Empty } = _Vue | ||
return (_openBlock(), _createBlock(\\"div\\", null, [ | ||
(_openBlock(), ok | ||
? _createBlock(\\"div\\", _hoisted_1, [ | ||
_hoisted_2 | ||
]) | ||
: _createBlock(_Empty)) | ||
])) | ||
} | ||
}" | ||
`; |
Oops, something went wrong.