feat(compiler): annotate patchFlags in generated code

This commit is contained in:
Evan You
2019-10-01 17:53:57 -04:00
parent 4021307f4c
commit 4fc963bc5a
7 changed files with 70 additions and 30 deletions

View File

@@ -107,7 +107,12 @@ describe('renderer: fragment', () => {
it('patch fragment children (compiler generated, unkeyed)', () => {
const root = nodeOps.createElement('div')
render(
createVNode(Fragment, null, [h('div', 'one'), 'two'], PatchFlags.UNKEYED),
createVNode(
Fragment,
null,
[h('div', 'one'), 'two'],
PatchFlags.UNKEYED_V_FOR
),
root
)
expect(serializeInner(root)).toBe(`<!----><div>one</div>two<!---->`)
@@ -117,7 +122,7 @@ describe('renderer: fragment', () => {
Fragment,
null,
[h('div', 'foo'), 'bar', 'baz'],
PatchFlags.UNKEYED
PatchFlags.UNKEYED_V_FOR
),
root
)
@@ -132,7 +137,7 @@ describe('renderer: fragment', () => {
Fragment,
null,
[h('div', { key: 1 }, 'one'), h('div', { key: 2 }, 'two')],
PatchFlags.KEYED
PatchFlags.KEYED_V_FOR
),
root
)
@@ -146,7 +151,7 @@ describe('renderer: fragment', () => {
Fragment,
null,
[h('div', { key: 2 }, 'two'), h('div', { key: 1 }, 'one')],
PatchFlags.KEYED
PatchFlags.KEYED_V_FOR
),
root
)

View File

@@ -1230,7 +1230,7 @@ export function createRenderer<
// fast path
const { patchFlag, shapeFlag } = n2
if (patchFlag) {
if (patchFlag & PatchFlags.KEYED) {
if (patchFlag & PatchFlags.KEYED_V_FOR) {
// this could be either fully-keyed or mixed (some keyed some not)
// presence of patchFlag means children are guaranteed to be arrays
patchKeyedChildren(
@@ -1244,7 +1244,7 @@ export function createRenderer<
optimized
)
return
} else if (patchFlag & PatchFlags.UNKEYED) {
} else if (patchFlag & PatchFlags.UNKEYED_V_FOR) {
// unkeyed
patchUnkeyedChildren(
c1 as HostVNode[],