Skip to content

Commit 1389d7b

Browse files
committed
refactor(compiler-core): use more concise marker for compiled slots
1 parent 175f8aa commit 1389d7b

File tree

11 files changed

+40
-40
lines changed

11 files changed

+40
-40
lines changed

packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const render = _withId(function render(_ctx, _cache) {
2929
default: _withId(() => [
3030
_createVNode(\\"div\\")
3131
]),
32-
_compiled: true
32+
_: 1
3333
}))
3434
})"
3535
`;
@@ -41,7 +41,7 @@ const _withId = _withScopeId(\\"test\\")
4141
export const render = _withId(function render(_ctx, _cache) {
4242
const _component_Child = _resolveComponent(\\"Child\\")
4343
44-
return (_openBlock(), _createBlock(_component_Child, null, _createSlots({ _compiled: true }, [
44+
return (_openBlock(), _createBlock(_component_Child, null, _createSlots({ _: 1 }, [
4545
(_ctx.ok)
4646
? {
4747
name: \\"foo\\",
@@ -76,7 +76,7 @@ export const render = _withId(function render(_ctx, _cache) {
7676
bar: _withId(() => [
7777
_createVNode(\\"div\\")
7878
]),
79-
_compiled: true
79+
_: 1
8080
}))
8181
})"
8282
`;

packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ return function render(_ctx, _cache) {
247247
default: ({ foo }) => [
248248
_createTextVNode(_toDisplayString(_ctx.foo), 1 /* TEXT */)
249249
],
250-
_compiled: true
250+
_: 1
251251
}))
252252
}
253253
}"

packages/compiler-core/__tests__/transforms/__snapshots__/vSlot.spec.ts.snap

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ return function render(_ctx, _cache) {
99
return (_openBlock(), _createBlock(_component_Comp, null, {
1010
[_ctx.one]: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
1111
[_ctx.two]: ({ bar }) => [_toDisplayString(_ctx.foo), _toDisplayString(bar)],
12-
_compiled: true
12+
_: 1
1313
}, 512 /* DYNAMIC_SLOTS */))
1414
}"
1515
`;
@@ -24,7 +24,7 @@ return function render(_ctx, _cache) {
2424
default: () => [
2525
_createVNode(\\"div\\")
2626
],
27-
_compiled: true
27+
_: 1
2828
}))
2929
}"
3030
`;
@@ -35,7 +35,7 @@ exports[`compiler: transform component slots named slot with v-for w/ prefixIden
3535
return function render(_ctx, _cache) {
3636
const _component_Comp = _resolveComponent(\\"Comp\\")
3737
38-
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
38+
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _: 1 }, [
3939
_renderList(_ctx.list, (name) => {
4040
return {
4141
name: name,
@@ -52,7 +52,7 @@ exports[`compiler: transform component slots named slot with v-if + prefixIdenti
5252
return function render(_ctx, _cache) {
5353
const _component_Comp = _resolveComponent(\\"Comp\\")
5454
55-
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
55+
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _: 1 }, [
5656
(_ctx.ok)
5757
? {
5858
name: \\"one\\",
@@ -72,7 +72,7 @@ return function render(_ctx, _cache) {
7272
7373
const _component_Comp = _resolveComponent(\\"Comp\\")
7474
75-
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
75+
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _: 1 }, [
7676
ok
7777
? {
7878
name: \\"one\\",
@@ -101,7 +101,7 @@ return function render(_ctx, _cache) {
101101
102102
const _component_Comp = _resolveComponent(\\"Comp\\")
103103
104-
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _compiled: true }, [
104+
return (_openBlock(), _createBlock(_component_Comp, null, _createSlots({ _: 1 }, [
105105
ok
106106
? {
107107
name: \\"one\\",
@@ -122,7 +122,7 @@ return function render(_ctx, _cache) {
122122
return (_openBlock(), _createBlock(_component_Comp, null, {
123123
one: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
124124
two: ({ bar }) => [_toDisplayString(_ctx.foo), _toDisplayString(bar)],
125-
_compiled: true
125+
_: 1
126126
}))
127127
}"
128128
`;
@@ -142,7 +142,7 @@ return function render(_ctx, _cache) {
142142
\\"bar\\",
143143
_createVNode(\\"span\\")
144144
],
145-
_compiled: true
145+
_: 1
146146
}))
147147
}
148148
}"
@@ -159,14 +159,14 @@ return function render(_ctx, _cache) {
159159
default: ({ foo }) => [
160160
_createVNode(_component_Inner, null, {
161161
default: ({ bar }) => [_toDisplayString(foo), _toDisplayString(bar), _toDisplayString(_ctx.baz)],
162-
_compiled: true
162+
_: 1
163163
}, 512 /* DYNAMIC_SLOTS */),
164164
\\" \\",
165165
_toDisplayString(foo),
166166
_toDisplayString(_ctx.bar),
167167
_toDisplayString(_ctx.baz)
168168
],
169-
_compiled: true
169+
_: 1
170170
}))
171171
}"
172172
`;
@@ -179,7 +179,7 @@ return function render(_ctx, _cache) {
179179
180180
return (_openBlock(), _createBlock(_component_Comp, null, {
181181
default: ({ foo }) => [_toDisplayString(foo), _toDisplayString(_ctx.bar)],
182-
_compiled: true
182+
_: 1
183183
}))
184184
}"
185185
`;

packages/compiler-core/__tests__/transforms/transformElement.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ describe('compiler: element transform', () => {
321321
fallback: {
322322
type: NodeTypes.JS_FUNCTION_EXPRESSION
323323
},
324-
_compiled: `[true]`
324+
_: `[1]`
325325
})
326326
: createObjectMatcher({
327327
default: {
328328
type: NodeTypes.JS_FUNCTION_EXPRESSION
329329
},
330-
_compiled: `[true]`
330+
_: `[1]`
331331
})
332332
})
333333
}
@@ -381,7 +381,7 @@ describe('compiler: element transform', () => {
381381
default: {
382382
type: NodeTypes.JS_FUNCTION_EXPRESSION
383383
},
384-
_compiled: `[true]`
384+
_: `[1]`
385385
})
386386
})
387387
}

packages/compiler-core/__tests__/transforms/vSlot.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ function createSlotMatcher(obj: Record<string, any>) {
6969
} as any
7070
})
7171
.concat({
72-
key: { content: `_compiled` },
73-
value: { content: `true` }
72+
key: { content: `_` },
73+
value: { content: `1`, isStatic: false }
7474
})
7575
}
7676
}
@@ -456,7 +456,7 @@ describe('compiler: transform component slots', () => {
456456
callee: CREATE_SLOTS,
457457
arguments: [
458458
createObjectMatcher({
459-
_compiled: `[true]`
459+
_: `[1]`
460460
}),
461461
{
462462
type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -498,7 +498,7 @@ describe('compiler: transform component slots', () => {
498498
callee: CREATE_SLOTS,
499499
arguments: [
500500
createObjectMatcher({
501-
_compiled: `[true]`
501+
_: `[1]`
502502
}),
503503
{
504504
type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -547,7 +547,7 @@ describe('compiler: transform component slots', () => {
547547
callee: CREATE_SLOTS,
548548
arguments: [
549549
createObjectMatcher({
550-
_compiled: `[true]`
550+
_: `[1]`
551551
}),
552552
{
553553
type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -606,7 +606,7 @@ describe('compiler: transform component slots', () => {
606606
callee: CREATE_SLOTS,
607607
arguments: [
608608
createObjectMatcher({
609-
_compiled: `[true]`
609+
_: `[1]`
610610
}),
611611
{
612612
type: NodeTypes.JS_ARRAY_EXPRESSION,

packages/compiler-core/src/transforms/vSlot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function buildSlots(
315315

316316
let slots = createObjectExpression(
317317
slotsProperties.concat(
318-
createObjectProperty(`_compiled`, createSimpleExpression(`true`, false))
318+
createObjectProperty(`_`, createSimpleExpression(`1`, false))
319319
),
320320
loc
321321
) as SlotsExpression

packages/compiler-ssr/__tests__/ssrComponent.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('ssr: components', () => {
6161
]
6262
}
6363
},
64-
_compiled: true
64+
_: 1
6565
}, _parent))
6666
}"
6767
`)
@@ -86,7 +86,7 @@ describe('ssr: components', () => {
8686
]
8787
}
8888
},
89-
_compiled: true
89+
_: 1
9090
}, _parent))
9191
}"
9292
`)
@@ -124,7 +124,7 @@ describe('ssr: components', () => {
124124
]
125125
}
126126
},
127-
_compiled: true
127+
_: 1
128128
}, _parent))
129129
}"
130130
`)
@@ -142,7 +142,7 @@ describe('ssr: components', () => {
142142
return function ssrRender(_ctx, _push, _parent) {
143143
const _component_foo = _resolveComponent(\\"foo\\")
144144
145-
_push(_ssrRenderComponent(_component_foo, null, _createSlots({ _compiled: true }, [
145+
_push(_ssrRenderComponent(_component_foo, null, _createSlots({ _: 1 }, [
146146
(_ctx.ok)
147147
? {
148148
name: \\"named\\",
@@ -174,7 +174,7 @@ describe('ssr: components', () => {
174174
return function ssrRender(_ctx, _push, _parent) {
175175
const _component_foo = _resolveComponent(\\"foo\\")
176176
177-
_push(_ssrRenderComponent(_component_foo, null, _createSlots({ _compiled: true }, [
177+
_push(_ssrRenderComponent(_component_foo, null, _createSlots({ _: 1 }, [
178178
_renderList(_ctx.names, (key) => {
179179
return {
180180
name: key,
@@ -262,7 +262,7 @@ describe('ssr: components', () => {
262262
]
263263
}
264264
},
265-
_compiled: true
265+
_: 1
266266
}, _parent))
267267
}"
268268
`)

packages/compiler-ssr/__tests__/ssrScopeId.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('ssr: scopeId', () => {
3939
]
4040
}
4141
},
42-
_compiled: true
42+
_: 1
4343
}, _parent))
4444
}"
4545
`)
@@ -67,7 +67,7 @@ describe('ssr: scopeId', () => {
6767
]
6868
}
6969
},
70-
_compiled: true
70+
_: 1
7171
}, _parent))
7272
}"
7373
`)
@@ -100,7 +100,7 @@ describe('ssr: scopeId', () => {
100100
]
101101
}
102102
},
103-
_compiled: true
103+
_: 1
104104
}, _parent))
105105
} else {
106106
return [
@@ -109,12 +109,12 @@ describe('ssr: scopeId', () => {
109109
default: () => [
110110
_createVNode(\\"span\\")
111111
],
112-
_compiled: true
112+
_: 1
113113
})
114114
]
115115
}
116116
},
117-
_compiled: true
117+
_: 1
118118
}, _parent))
119119
}"
120120
`)

packages/runtime-core/src/componentSlots.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type RawSlots = {
2323
// manual render fn hint to skip forced children updates
2424
$stable?: boolean
2525
// internal, indicates compiler generated slots = can skip normalization
26-
_compiled?: boolean
26+
_?: 1
2727
}
2828

2929
const normalizeSlotValue = (value: unknown): VNode[] =>
@@ -51,7 +51,7 @@ export function resolveSlots(
5151
let slots: InternalSlots | void
5252
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
5353
const rawSlots = children as RawSlots
54-
if (rawSlots._compiled) {
54+
if (rawSlots._ === 1) {
5555
// pre-normalized slots object generated by compiler
5656
slots = children as Slots
5757
} else {

packages/runtime-core/src/helpers/renderSlot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function renderSlot(
3535
Fragment,
3636
{ key: props.key },
3737
slot ? slot(props) : fallback || [],
38-
slots._compiled ? 0 : PatchFlags.BAIL
38+
slots._ ? 0 : PatchFlags.BAIL
3939
)
4040
)
4141
}

packages/server-renderer/__tests__/renderToString.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('ssr: renderToString', () => {
218218
push(`<span>${msg}</span>`)
219219
},
220220
// important to avoid slots being normalized
221-
_compiled: true as any
221+
_: 1 as any
222222
},
223223
parent
224224
)

0 commit comments

Comments
 (0)