Skip to content

Commit e12b10a

Browse files
committed
chore: Merge branch 'main' into minor
2 parents 53aaa1e + d5a88ef commit e12b10a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+930
-279
lines changed

CHANGELOG.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
## [3.3.10](https://github.com/vuejs/core/compare/v3.3.9...v3.3.10) (2023-12-04)
2+
3+
4+
### Bug Fixes
5+
6+
* **app:** prevent template from being cached between apps with different options ([#9724](https://github.com/vuejs/core/issues/9724)) ([ec71585](https://github.com/vuejs/core/commit/ec715854ca12520b2afc9e9b3981cbae05ae5206)), closes [#9618](https://github.com/vuejs/core/issues/9618)
7+
* **compiler-sfc:** avoid passing forEach index to genMap ([f12db7f](https://github.com/vuejs/core/commit/f12db7fb564a534cef2e5805cc9f54afe5d72fbf))
8+
* **compiler-sfc:** deindent pug/jade templates ([6345197](https://github.com/vuejs/core/commit/634519720a21fb5a6871454e1cadad7053a568b8)), closes [#3231](https://github.com/vuejs/core/issues/3231) [#3842](https://github.com/vuejs/core/issues/3842) [#7723](https://github.com/vuejs/core/issues/7723)
9+
* **compiler-sfc:** fix :where and :is selector in scoped mode with multiple selectors ([#9735](https://github.com/vuejs/core/issues/9735)) ([c3e2c55](https://github.com/vuejs/core/commit/c3e2c556b532656b50b8ab5cd2d9eabc26622d63)), closes [#9707](https://github.com/vuejs/core/issues/9707)
10+
* **compiler-sfc:** generate more treeshaking friendly code ([#9507](https://github.com/vuejs/core/issues/9507)) ([8d74ca0](https://github.com/vuejs/core/commit/8d74ca0e6fa2738ca6854b7e879ff59419f948c7)), closes [#9500](https://github.com/vuejs/core/issues/9500)
11+
* **compiler-sfc:** support inferring generic types ([#8511](https://github.com/vuejs/core/issues/8511)) ([eb5e307](https://github.com/vuejs/core/commit/eb5e307c0be62002e62c4c800d0dfacb39b0d4ca)), closes [#8482](https://github.com/vuejs/core/issues/8482)
12+
* **compiler-sfc:** support resolving components from props ([#8785](https://github.com/vuejs/core/issues/8785)) ([7cbcee3](https://github.com/vuejs/core/commit/7cbcee3d831241a8bd3588ae92d3f27e3641e25f))
13+
* **compiler-sfc:** throw error when failing to load TS during type resolution ([#8883](https://github.com/vuejs/core/issues/8883)) ([4936d2e](https://github.com/vuejs/core/commit/4936d2e11a8d0ca3704bfe408548cb26bb3fd5e9))
14+
* **cssVars:** cssVar names should be double-escaped when generating code for ssr ([#8824](https://github.com/vuejs/core/issues/8824)) ([5199a12](https://github.com/vuejs/core/commit/5199a12f8855cd06f24bf355708b5a2134f63176)), closes [#7823](https://github.com/vuejs/core/issues/7823)
15+
* **deps:** update compiler to ^7.23.4 ([#9681](https://github.com/vuejs/core/issues/9681)) ([31f6ebc](https://github.com/vuejs/core/commit/31f6ebc4df84490ed29fb75e7bf4259200eb51f0))
16+
* **runtime-core:** Suspense get anchor properly in Transition ([#9309](https://github.com/vuejs/core/issues/9309)) ([65f3fe2](https://github.com/vuejs/core/commit/65f3fe273127a8b68e1222fbb306d28d85f01757)), closes [#8105](https://github.com/vuejs/core/issues/8105)
17+
* **runtime-dom:** set width/height with units as attribute ([#8781](https://github.com/vuejs/core/issues/8781)) ([bfc1838](https://github.com/vuejs/core/commit/bfc1838f31199de3f189198a3c234fa7bae91386))
18+
* **ssr:** avoid computed being accidentally cached before server render ([#9688](https://github.com/vuejs/core/issues/9688)) ([30d5d93](https://github.com/vuejs/core/commit/30d5d93a92b2154406ec04f8aca6b217fa01177c)), closes [#5300](https://github.com/vuejs/core/issues/5300)
19+
* **types:** expose emits as props in functional components ([#9234](https://github.com/vuejs/core/issues/9234)) ([887e54c](https://github.com/vuejs/core/commit/887e54c347ea9eac4c721b5e2288f054873d1d30))
20+
* **types:** fix reactive collection types ([#8960](https://github.com/vuejs/core/issues/8960)) ([ad27473](https://github.com/vuejs/core/commit/ad274737015c36906d76f3189203093fa3a2e4e7)), closes [#8904](https://github.com/vuejs/core/issues/8904)
21+
* **types:** improve return type withKeys and withModifiers ([#9734](https://github.com/vuejs/core/issues/9734)) ([43c3cfd](https://github.com/vuejs/core/commit/43c3cfdec5ae5d70fa2a21e857abc2d73f1a0d07))
22+
23+
24+
### Performance Improvements
25+
26+
* optimize on* prop check ([38aaa8c](https://github.com/vuejs/core/commit/38aaa8c88648c54fe2616ad9c0961288092fcb44))
27+
* **runtime-dom:** cache modifier wrapper functions ([da4a4fb](https://github.com/vuejs/core/commit/da4a4fb5e8eee3c6d31f24ebd79a9d0feca56cb2)), closes [#8882](https://github.com/vuejs/core/issues/8882)
28+
* **v-on:** constant handlers with modifiers should not be treated as dynamic ([4d94ebf](https://github.com/vuejs/core/commit/4d94ebfe75174b340d2b794e699cad1add3600a9))
29+
30+
31+
132
# [3.4.0-alpha.3](https://github.com/vuejs/core/compare/v3.4.0-alpha.2...v3.4.0-alpha.3) (2023-11-28)
233

334

@@ -97,7 +128,7 @@
97128
* **compiler-sfc:** fix dynamic directive arguments usage check for slots ([#9495](https://github.com/vuejs/core/issues/9495)) ([b39fa1f](https://github.com/vuejs/core/commit/b39fa1f8157647859331ce439c42ae016a49b415)), closes [#9493](https://github.com/vuejs/core/issues/9493)
98129
* **deps:** update dependency @vue/repl to ^2.6.2 ([#9536](https://github.com/vuejs/core/issues/9536)) ([5cef325](https://github.com/vuejs/core/commit/5cef325f41e3b38657c72fa1a38dedeee1c7a60a))
99130
* **deps:** update dependency @vue/repl to ^2.6.3 ([#9540](https://github.com/vuejs/core/issues/9540)) ([176d590](https://github.com/vuejs/core/commit/176d59058c9aecffe9da4d4311e98496684f06d4))
100-
* **hydration:** fix tagName access eeror on comment/text node hydration mismatch ([dd8a0cf](https://github.com/vuejs/core/commit/dd8a0cf5dcde13d2cbd899262a0e07f16e14e489)), closes [#9531](https://github.com/vuejs/core/issues/9531)
131+
* **hydration:** fix tagName access error on comment/text node hydration mismatch ([dd8a0cf](https://github.com/vuejs/core/commit/dd8a0cf5dcde13d2cbd899262a0e07f16e14e489)), closes [#9531](https://github.com/vuejs/core/issues/9531)
101132
* **types:** avoid exposing lru-cache types in generated dts ([462aeb3](https://github.com/vuejs/core/commit/462aeb3b600765e219ded2ee9a0ed1e74df61de0)), closes [#9521](https://github.com/vuejs/core/issues/9521)
102133
* **warn:** avoid warning on empty children with Suspense ([#3962](https://github.com/vuejs/core/issues/3962)) ([405f345](https://github.com/vuejs/core/commit/405f34587a63a5f1e3d147b9848219ea98acc22d))
103134

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"node": ">=18.12.0"
5858
},
5959
"devDependencies": {
60-
"@babel/parser": "^7.23.4",
61-
"@babel/types": "^7.23.4",
60+
"@babel/parser": "^7.23.5",
61+
"@babel/types": "^7.23.5",
6262
"@rollup/plugin-alias": "^5.0.1",
6363
"@rollup/plugin-commonjs": "^25.0.7",
6464
"@rollup/plugin-json": "^6.0.1",
@@ -67,7 +67,7 @@
6767
"@rollup/plugin-terser": "^0.4.4",
6868
"@types/hash-sum": "^1.0.2",
6969
"@types/minimist": "^1.2.5",
70-
"@types/node": "^20.10.0",
70+
"@types/node": "^20.10.3",
7171
"@types/semver": "^7.5.5",
7272
"@typescript-eslint/parser": "^6.13.0",
7373
"@vitest/coverage-istanbul": "^0.34.6",
@@ -93,7 +93,7 @@
9393
"prettier": "^3.1.0",
9494
"pretty-bytes": "^6.1.1",
9595
"pug": "^3.0.2",
96-
"puppeteer": "~21.5.1",
96+
"puppeteer": "~21.5.2",
9797
"rimraf": "^5.0.5",
9898
"rollup": "^4.1.4",
9999
"rollup-plugin-dts": "^6.1.0",
@@ -105,7 +105,7 @@
105105
"terser": "^5.22.0",
106106
"todomvc-app-css": "^2.4.3",
107107
"tslib": "^2.6.2",
108-
"tsx": "^4.5.0",
108+
"tsx": "^4.6.2",
109109
"typescript": "^5.2.2",
110110
"vite": "^5.0.0",
111111
"vitest": "^0.34.6"

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,28 @@ describe('compiler: element transform', () => {
152152
expect(node.tag).toBe(`Foo.Example`)
153153
})
154154

155+
test('resolve namespaced component from props bindings (inline)', () => {
156+
const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
157+
inline: true,
158+
bindingMetadata: {
159+
Foo: BindingTypes.PROPS
160+
}
161+
})
162+
expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
163+
expect(node.tag).toBe(`_unref(__props["Foo"]).Example`)
164+
})
165+
166+
test('resolve namespaced component from props bindings (non-inline)', () => {
167+
const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
168+
inline: false,
169+
bindingMetadata: {
170+
Foo: BindingTypes.PROPS
171+
}
172+
})
173+
expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
174+
expect(node.tag).toBe('_unref($props["Foo"]).Example')
175+
})
176+
155177
test('do not resolve component from non-script-setup bindings', () => {
156178
const bindingMetadata = {
157179
Example: BindingTypes.SETUP_MAYBE_REF
@@ -1138,6 +1160,20 @@ describe('compiler: element transform', () => {
11381160
genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
11391161
)
11401162
})
1163+
1164+
test('should not have PROPS patchflag for constant v-on handlers', () => {
1165+
const { node } = parseWithElementTransform(`<div @keydown="foo" />`, {
1166+
prefixIdentifiers: true,
1167+
bindingMetadata: {
1168+
foo: BindingTypes.SETUP_CONST
1169+
},
1170+
directiveTransforms: {
1171+
on: transformOn
1172+
}
1173+
})
1174+
// should only have hydration flag
1175+
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_HYDRATION))
1176+
})
11411177
})
11421178

11431179
describe('dynamic component', () => {

packages/compiler-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
35-
"@babel/parser": "^7.23.4",
35+
"@babel/parser": "^7.23.5",
3636
"@vue/shared": "workspace:*",
3737
"entities": "^4.5.0",
3838
"estree-walker": "^2.0.2",
3939
"source-map-js": "^1.0.2"
4040
},
4141
"devDependencies": {
42-
"@babel/types": "^7.23.4"
42+
"@babel/types": "^7.23.5"
4343
}
4444
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
TemplateTextChildNode,
2020
DirectiveArguments,
2121
createVNodeCall,
22-
ConstantTypes
22+
ConstantTypes,
23+
JSChildNode
2324
} from '../ast'
2425
import {
2526
PatchFlags,
@@ -370,6 +371,13 @@ function resolveSetupReference(name: string, context: TransformContext) {
370371
`${context.helperString(UNREF)}(${fromMaybeRef})`
371372
: `$setup[${JSON.stringify(fromMaybeRef)}]`
372373
}
374+
375+
const fromProps = checkType(BindingTypes.PROPS)
376+
if (fromProps) {
377+
return `${context.helperString(UNREF)}(${
378+
context.inline ? '__props' : '$props'
379+
}[${JSON.stringify(fromProps)}])`
380+
}
373381
}
374382

375383
export type PropsExpression = ObjectExpression | CallExpression | ExpressionNode
@@ -437,6 +445,12 @@ export function buildProps(
437445
hasVnodeHook = true
438446
}
439447

448+
if (isEventHandler && value.type === NodeTypes.JS_CALL_EXPRESSION) {
449+
// handler wrapped with internal helper e.g. withModifiers(fn)
450+
// extract the actual expression
451+
value = value.arguments[0] as JSChildNode
452+
}
453+
440454
if (
441455
value.type === NodeTypes.JS_CACHE_EXPRESSION ||
442456
((value.type === NodeTypes.SIMPLE_EXPRESSION ||

packages/compiler-dom/__tests__/transforms/vOn.spec.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
NodeTypes,
88
ObjectExpression,
99
transform,
10-
VNodeCall
10+
VNodeCall,
11+
BindingTypes
1112
} from '@vue/compiler-core'
1213
import { transformOn } from '../../src/transforms/vOn'
1314
import { V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS } from '../../src/runtimeHelpers'
@@ -25,12 +26,11 @@ function parseWithVOn(template: string, options: CompilerOptions = {}) {
2526
},
2627
...options
2728
})
29+
const node = (ast.children[0] as ElementNode).codegenNode as VNodeCall
2830
return {
2931
root: ast,
30-
props: (
31-
((ast.children[0] as ElementNode).codegenNode as VNodeCall)
32-
.props as ObjectExpression
33-
).properties
32+
node,
33+
props: (node.props as ObjectExpression).properties
3434
}
3535
}
3636

@@ -288,4 +288,18 @@ describe('compiler-dom: transform v-on', () => {
288288
}
289289
})
290290
})
291+
292+
test('should not have PROPS patchFlag for constant v-on handlers with modifiers', () => {
293+
const { node } = parseWithVOn(`<div @keydown.up="foo" />`, {
294+
prefixIdentifiers: true,
295+
bindingMetadata: {
296+
foo: BindingTypes.SETUP_CONST
297+
},
298+
directiveTransforms: {
299+
on: transformOn
300+
}
301+
})
302+
// should only have hydration flag
303+
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_HYDRATION))
304+
})
291305
})

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,10 +1065,12 @@ export default {
10651065
setup(__props) {
10661066

10671067
const count = ref(0)
1068+
const style = { color: 'red' }
10681069

10691070
return (_ctx, _push, _parent, _attrs) => {
10701071
const _cssVars = { style: {
1071-
\\"--xxxxxxxx-count\\": (count.value)
1072+
\\"--xxxxxxxx-count\\": (count.value),
1073+
\\"--xxxxxxxx-style\\\\\\\\.color\\": (style.color)
10721074
}}
10731075
_push(\`<!--[--><div\${
10741076
_ssrRenderAttrs(_cssVars)

packages/compiler-sfc/__tests__/compileScript.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,15 @@ describe('SFC compile <script setup>', () => {
826826
<script setup>
827827
import { ref } from 'vue'
828828
const count = ref(0)
829+
const style = { color: 'red' }
829830
</script>
830831
<template>
831832
<div>{{ count }}</div>
832833
<div>static</div>
833834
</template>
834835
<style>
835836
div { color: v-bind(count) }
837+
span { color: v-bind(style.color) }
836838
</style>
837839
`,
838840
{
@@ -847,6 +849,7 @@ describe('SFC compile <script setup>', () => {
847849
expect(content).toMatch(`ssrInterpolate`)
848850
expect(content).not.toMatch(`useCssVars`)
849851
expect(content).toMatch(`"--${mockId}-count": (count.value)`)
852+
expect(content).toMatch(`"--${mockId}-style\\\\.color": (style.color)`)
850853
assertCode(content)
851854
})
852855

packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineModel.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exports[`defineModel() > w/ array props 1`] = `
2727
"import { useModel as _useModel, mergeModels as _mergeModels } from 'vue'
2828
2929
export default {
30-
props: _mergeModels(['foo', 'bar'], {
30+
props: /*#__PURE__*/_mergeModels(['foo', 'bar'], {
3131
\\"count\\": {},
3232
}),
3333
emits: [\\"update:count\\"],
@@ -47,10 +47,10 @@ exports[`defineModel() > w/ defineProps and defineEmits 1`] = `
4747
"import { useModel as _useModel, mergeModels as _mergeModels } from 'vue'
4848
4949
export default {
50-
props: _mergeModels({ foo: String }, {
50+
props: /*#__PURE__*/_mergeModels({ foo: String }, {
5151
\\"modelValue\\": { default: 0 },
5252
}),
53-
emits: _mergeModels(['change'], [\\"update:modelValue\\"]),
53+
emits: /*#__PURE__*/_mergeModels(['change'], [\\"update:modelValue\\"]),
5454
setup(__props, { expose: __expose }) {
5555
__expose();
5656

packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineProps.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ exports[`defineProps > withDefaults (dynamic) 1`] = `
332332
import { defaults } from './foo'
333333
334334
export default /*#__PURE__*/_defineComponent({
335-
props: _mergeDefaults({
335+
props: /*#__PURE__*/_mergeDefaults({
336336
foo: { type: String, required: false },
337337
bar: { type: Number, required: false },
338338
baz: { type: Boolean, required: true }
@@ -353,7 +353,7 @@ exports[`defineProps > withDefaults (dynamic) w/ production mode 1`] = `
353353
import { defaults } from './foo'
354354
355355
export default /*#__PURE__*/_defineComponent({
356-
props: _mergeDefaults({
356+
props: /*#__PURE__*/_mergeDefaults({
357357
foo: { type: Function },
358358
bar: { type: Boolean },
359359
baz: { type: [Boolean, Function] },
@@ -375,7 +375,7 @@ exports[`defineProps > withDefaults (reference) 1`] = `
375375
import { defaults } from './foo'
376376
377377
export default /*#__PURE__*/_defineComponent({
378-
props: _mergeDefaults({
378+
props: /*#__PURE__*/_mergeDefaults({
379379
foo: { type: String, required: false },
380380
bar: { type: Number, required: false },
381381
baz: { type: Boolean, required: true }
@@ -462,7 +462,7 @@ exports[`defineProps > withDefaults w/ dynamic object method 1`] = `
462462
"import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from 'vue'
463463
464464
export default /*#__PURE__*/_defineComponent({
465-
props: _mergeDefaults({
465+
props: /*#__PURE__*/_mergeDefaults({
466466
foo: { type: Function, required: false }
467467
}, {
468468
['fo' + 'o']() { return 'foo' }

packages/compiler-sfc/__tests__/compileScript/__snapshots__/definePropsDestructure.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ exports[`sfc reactive props destructure > default values w/ array runtime declar
6262
"import { mergeDefaults as _mergeDefaults } from 'vue'
6363
6464
export default {
65-
props: _mergeDefaults(['foo', 'bar', 'baz'], {
65+
props: /*#__PURE__*/_mergeDefaults(['foo', 'bar', 'baz'], {
6666
foo: 1,
6767
bar: () => ({}),
6868
func: () => {}, __skip_func: true
@@ -81,7 +81,7 @@ exports[`sfc reactive props destructure > default values w/ object runtime decla
8181
"import { mergeDefaults as _mergeDefaults } from 'vue'
8282
8383
export default {
84-
props: _mergeDefaults({ foo: Number, bar: Object, func: Function, ext: null }, {
84+
props: /*#__PURE__*/_mergeDefaults({ foo: Number, bar: Object, func: Function, ext: null }, {
8585
foo: 1,
8686
bar: () => ({}),
8787
func: () => {}, __skip_func: true,
@@ -101,7 +101,7 @@ exports[`sfc reactive props destructure > default values w/ runtime declaration
101101
"import { mergeDefaults as _mergeDefaults } from 'vue'
102102
103103
export default {
104-
props: _mergeDefaults(['foo', 'foo:bar'], {
104+
props: /*#__PURE__*/_mergeDefaults(['foo', 'foo:bar'], {
105105
foo: 1,
106106
\\"foo:bar\\": 'foo-bar'
107107
}),

packages/compiler-sfc/__tests__/compileScript/defineModel.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('defineModel()', () => {
4848
{ defineModel: true }
4949
)
5050
assertCode(content)
51-
expect(content).toMatch(`props: _mergeModels({ foo: String }`)
51+
expect(content).toMatch(`props: /*#__PURE__*/_mergeModels({ foo: String }`)
5252
expect(content).toMatch(`"modelValue": { default: 0 }`)
5353
expect(content).toMatch(`const count = _useModel(__props, "modelValue")`)
5454
expect(content).not.toMatch('defineModel')
@@ -70,7 +70,7 @@ describe('defineModel()', () => {
7070
{ defineModel: true }
7171
)
7272
assertCode(content)
73-
expect(content).toMatch(`props: _mergeModels(['foo', 'bar'], {
73+
expect(content).toMatch(`props: /*#__PURE__*/_mergeModels(['foo', 'bar'], {
7474
"count": {},
7575
})`)
7676
expect(content).toMatch(`const count = _useModel(__props, "count")`)

packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ describe('sfc reactive props destructure', () => {
7878
// literals can be used as-is, non-literals are always returned from a
7979
// function
8080
// functions need to be marked with a skip marker
81-
expect(content).toMatch(`props: _mergeDefaults(['foo', 'bar', 'baz'], {
81+
expect(content)
82+
.toMatch(`props: /*#__PURE__*/_mergeDefaults(['foo', 'bar', 'baz'], {
8283
foo: 1,
8384
bar: () => ({}),
8485
func: () => {}, __skip_func: true
@@ -98,7 +99,7 @@ describe('sfc reactive props destructure', () => {
9899
// safely infer whether runtime type is Function (e.g. if the runtime decl
99100
// is imported, or spreads another object)
100101
expect(content)
101-
.toMatch(`props: _mergeDefaults({ foo: Number, bar: Object, func: Function, ext: null }, {
102+
.toMatch(`props: /*#__PURE__*/_mergeDefaults({ foo: Number, bar: Object, func: Function, ext: null }, {
102103
foo: 1,
103104
bar: () => ({}),
104105
func: () => {}, __skip_func: true,
@@ -122,7 +123,7 @@ describe('sfc reactive props destructure', () => {
122123
})
123124

124125
expect(content).toMatch(`
125-
props: _mergeDefaults(['foo', 'foo:bar'], {
126+
props: /*#__PURE__*/_mergeDefaults(['foo', 'foo:bar'], {
126127
foo: 1,
127128
"foo:bar": 'foo-bar'
128129
}),`)

0 commit comments

Comments
 (0)