perf: hoist dynamic props lists
This commit is contained in:
@@ -319,15 +319,18 @@ return function render(_ctx, _cache) {
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: hoistStatic transform should NOT hoist element with dynamic props 1`] = `
|
||||
exports[`compiler: hoistStatic transform should NOT hoist element with dynamic props (but hoist the props list) 1`] = `
|
||||
"const _Vue = Vue
|
||||
const { createElementVNode: _createElementVNode } = _Vue
|
||||
|
||||
const _hoisted_1 = [\\"id\\"]
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
with (_ctx) {
|
||||
const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _createElementBlock(\\"div\\", null, [
|
||||
_createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"])
|
||||
_createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, _hoisted_1)
|
||||
]))
|
||||
}
|
||||
}"
|
||||
|
||||
@@ -186,9 +186,9 @@ describe('compiler: hoistStatic transform', () => {
|
||||
expect(generate(root).code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should NOT hoist element with dynamic props', () => {
|
||||
test('should NOT hoist element with dynamic props (but hoist the props list)', () => {
|
||||
const root = transformWithHoist(`<div><div :id="foo"/></div>`)
|
||||
expect(root.hoists.length).toBe(0)
|
||||
expect(root.hoists.length).toBe(1)
|
||||
expect((root.codegenNode as VNodeCall).children).toMatchObject([
|
||||
{
|
||||
type: NodeTypes.ELEMENT,
|
||||
@@ -200,7 +200,11 @@ describe('compiler: hoistStatic transform', () => {
|
||||
}),
|
||||
children: undefined,
|
||||
patchFlag: genFlagText(PatchFlags.PROPS),
|
||||
dynamicProps: `["id"]`
|
||||
dynamicProps: {
|
||||
type: NodeTypes.SIMPLE_EXPRESSION,
|
||||
content: `_hoisted_1`,
|
||||
isStatic: false
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user