vue 2.7.13 → 2.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/vue.common.dev.js +219 -200
  2. package/dist/vue.common.prod.js +5 -5
  3. package/dist/vue.esm.browser.js +219 -200
  4. package/dist/vue.esm.browser.min.js +5 -5
  5. package/dist/vue.esm.js +223 -203
  6. package/dist/vue.js +223 -203
  7. package/dist/vue.min.js +5 -5
  8. package/dist/vue.runtime.common.dev.js +113 -92
  9. package/dist/vue.runtime.common.prod.js +5 -5
  10. package/dist/vue.runtime.esm.js +114 -92
  11. package/dist/vue.runtime.js +114 -92
  12. package/dist/vue.runtime.min.js +5 -5
  13. package/package.json +7 -7
  14. package/packages/compiler-sfc/dist/compiler-sfc.js +43 -28
  15. package/packages/compiler-sfc/node_modules/.bin/lessc +4 -4
  16. package/packages/compiler-sfc/node_modules/.bin/parser +4 -4
  17. package/packages/compiler-sfc/node_modules/.bin/sass +4 -4
  18. package/packages/compiler-sfc/node_modules/.bin/stylus +4 -4
  19. package/packages/compiler-sfc/package.json +1 -1
  20. package/packages/compiler-sfc/src/compileScript.ts +13 -8
  21. package/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +41 -9
  22. package/packages/compiler-sfc/test/__snapshots__/cssVars.spec.ts.snap +1 -1
  23. package/packages/compiler-sfc/test/compileScript.spec.ts +45 -1
  24. package/src/compiler/codegen/index.ts +1 -1
  25. package/src/compiler/parser/html-parser.ts +1 -1
  26. package/src/compiler/parser/index.ts +1 -1
  27. package/src/core/instance/lifecycle.ts +8 -2
  28. package/src/core/observer/index.ts +3 -5
  29. package/src/core/util/options.ts +19 -3
  30. package/src/core/vdom/patch.ts +5 -2
  31. package/src/platforms/web/util/element.ts +1 -1
  32. package/src/shared/util.ts +1 -3
  33. package/src/types/utils.ts +1 -1
  34. package/src/v3/apiAsyncComponent.ts +1 -1
  35. package/src/v3/reactivity/reactive.ts +4 -6
  36. package/src/v3/reactivity/readonly.ts +11 -5
  37. package/types/common.d.ts +1 -1
  38. package/types/jsx.d.ts +3 -1
  39. package/types/options.d.ts +1 -1
  40. package/types/v3-setup-helpers.d.ts +5 -1
  41. package/types/vnode.d.ts +2 -1
  42. package/dist/compiler-sfc.js +0 -14
@@ -248,9 +248,7 @@ const identity = (_) => _;
248
248
  */
249
249
  function genStaticKeys$1(modules) {
250
250
  return modules
251
- .reduce((keys, m) => {
252
- return keys.concat(m.staticKeys || []);
253
- }, [])
251
+ .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
254
252
  .join(',');
255
253
  }
256
254
  /**
@@ -413,7 +411,7 @@ function parseHTML(html, options) {
413
411
  continue;
414
412
  }
415
413
  }
416
- // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
414
+ // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
417
415
  if (conditionalComment.test(html)) {
418
416
  const conditionalEnd = html.indexOf(']>');
419
417
  if (conditionalEnd >= 0) {
@@ -3643,13 +3641,8 @@ methodsToPatch.forEach(function (method) {
3643
3641
  });
3644
3642
  });
3645
3643
 
3646
- const rawMap = new WeakMap();
3647
- function isReadonly(value) {
3648
- return !!(value && value.__v_isReadonly);
3649
- }
3650
-
3651
3644
  const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
3652
- const NO_INIITIAL_VALUE = {};
3645
+ const NO_INITIAL_VALUE = {};
3653
3646
  /**
3654
3647
  * In some cases we may want to disable observation inside a component's
3655
3648
  * update computation.
@@ -3706,7 +3699,7 @@ class Observer {
3706
3699
  const keys = Object.keys(value);
3707
3700
  for (let i = 0; i < keys.length; i++) {
3708
3701
  const key = keys[i];
3709
- defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
3702
+ defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
3710
3703
  }
3711
3704
  }
3712
3705
  }
@@ -3734,7 +3727,6 @@ function observe(value, shallow, ssrMockReactivity) {
3734
3727
  (isArray(value) || isPlainObject(value)) &&
3735
3728
  Object.isExtensible(value) &&
3736
3729
  !value.__v_skip /* ReactiveFlags.SKIP */ &&
3737
- !rawMap.has(value) &&
3738
3730
  !isRef(value) &&
3739
3731
  !(value instanceof VNode)) {
3740
3732
  return new Observer(value, shallow, ssrMockReactivity);
@@ -3753,7 +3745,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
3753
3745
  const getter = property && property.get;
3754
3746
  const setter = property && property.set;
3755
3747
  if ((!getter || setter) &&
3756
- (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
3748
+ (val === NO_INITIAL_VALUE || arguments.length === 2)) {
3757
3749
  val = obj[key];
3758
3750
  }
3759
3751
  let childOb = !shallow && observe(val, false, mock);
@@ -3884,6 +3876,10 @@ function dependArray(value) {
3884
3876
  }
3885
3877
  }
3886
3878
 
3879
+ function isReadonly(value) {
3880
+ return !!(value && value.__v_isReadonly);
3881
+ }
3882
+
3887
3883
  function isRef(r) {
3888
3884
  return !!(r && r.__v_isRef === true);
3889
3885
  }
@@ -4788,7 +4784,7 @@ function deactivateChildComponent(vm, direct) {
4788
4784
  function callHook(vm, hook, args, setContext = true) {
4789
4785
  // #7573 disable dep collection when invoking lifecycle hooks
4790
4786
  pushTarget();
4791
- const prev = currentInstance;
4787
+ const prevInst = currentInstance;
4792
4788
  setContext && setCurrentInstance(vm);
4793
4789
  const handlers = vm.$options[hook];
4794
4790
  const info = `${hook} hook`;
@@ -4800,7 +4796,9 @@ function callHook(vm, hook, args, setContext = true) {
4800
4796
  if (vm._hasHookEvent) {
4801
4797
  vm.$emit('hook:' + hook);
4802
4798
  }
4803
- setContext && setCurrentInstance(prev);
4799
+ if (setContext) {
4800
+ setCurrentInstance(prevInst);
4801
+ }
4804
4802
  popTarget();
4805
4803
  }
4806
4804
 
@@ -5447,7 +5445,7 @@ if (process.env.NODE_ENV !== 'production') {
5447
5445
  /**
5448
5446
  * Helper that recursively merges two data objects together.
5449
5447
  */
5450
- function mergeData(to, from) {
5448
+ function mergeData(to, from, recursive = true) {
5451
5449
  if (!from)
5452
5450
  return to;
5453
5451
  let key, toVal, fromVal;
@@ -5461,7 +5459,7 @@ function mergeData(to, from) {
5461
5459
  continue;
5462
5460
  toVal = to[key];
5463
5461
  fromVal = from[key];
5464
- if (!hasOwn(to, key)) {
5462
+ if (!recursive || !hasOwn(to, key)) {
5465
5463
  set(to, key, fromVal);
5466
5464
  }
5467
5465
  else if (toVal !== fromVal &&
@@ -5622,7 +5620,19 @@ strats.props =
5622
5620
  extend(ret, childVal);
5623
5621
  return ret;
5624
5622
  };
5625
- strats.provide = mergeDataOrFn;
5623
+ strats.provide = function (parentVal, childVal) {
5624
+ if (!parentVal)
5625
+ return childVal;
5626
+ return function () {
5627
+ const ret = Object.create(null);
5628
+ mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
5629
+ if (childVal) {
5630
+ mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
5631
+ );
5632
+ }
5633
+ return ret;
5634
+ };
5635
+ };
5626
5636
  /**
5627
5637
  * Default strategy.
5628
5638
  */
@@ -8458,7 +8468,10 @@ function compileScript(sfc, options = { id: '' }) {
8458
8468
  }
8459
8469
  }
8460
8470
  if (declId) {
8461
- emitIdentifier = scriptSetup.content.slice(declId.start, declId.end);
8471
+ emitIdentifier =
8472
+ declId.type === 'Identifier'
8473
+ ? declId.name
8474
+ : scriptSetup.content.slice(declId.start, declId.end);
8462
8475
  }
8463
8476
  return true;
8464
8477
  }
@@ -8835,12 +8848,12 @@ function compileScript(sfc, options = { id: '' }) {
8835
8848
  else {
8836
8849
  let start = decl.start + startOffset;
8837
8850
  let end = decl.end + startOffset;
8838
- if (i < total - 1) {
8839
- // not the last one, locate the start of the next
8851
+ if (i === 0) {
8852
+ // first one, locate the start of the next
8840
8853
  end = node.declarations[i + 1].start + startOffset;
8841
8854
  }
8842
8855
  else {
8843
- // last one, locate the end of the prev
8856
+ // not first one, locate the end of the prev
8844
8857
  start = node.declarations[i - 1].end + startOffset;
8845
8858
  }
8846
8859
  s.remove(start, end);
@@ -9014,7 +9027,7 @@ function compileScript(sfc, options = { id: '' }) {
9014
9027
  // we use a default __props so that template expressions referencing props
9015
9028
  // can use it directly
9016
9029
  if (propsIdentifier) {
9017
- s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}\n`);
9030
+ s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``};\n`);
9018
9031
  }
9019
9032
  const destructureElements = hasDefineExposeCall ? [`expose`] : [];
9020
9033
  if (emitIdentifier) {
@@ -9537,9 +9550,11 @@ function resolveTemplateUsageCheckString(sfc, isTS) {
9537
9550
  if (dirRE.test(name)) {
9538
9551
  const baseName = onRE.test(name)
9539
9552
  ? 'on'
9540
- : bindRE.test(name)
9541
- ? 'bind'
9542
- : name.replace(dirRE, '');
9553
+ : slotRE.test(name)
9554
+ ? 'slot'
9555
+ : bindRE.test(name)
9556
+ ? 'bind'
9557
+ : name.replace(dirRE, '');
9543
9558
  if (!isBuiltInDir$1(baseName)) {
9544
9559
  code += `,v${capitalize(camelize(baseName))}`;
9545
9560
  }
@@ -9566,7 +9581,7 @@ function processExp(exp, isTS, dir) {
9566
9581
  exp = `(${exp})=>{}`;
9567
9582
  }
9568
9583
  else if (dir === 'on') {
9569
- exp = `()=>{${exp}}`;
9584
+ exp = `()=>{return ${exp}}`;
9570
9585
  }
9571
9586
  else if (dir === 'for') {
9572
9587
  const inMatch = exp.match(forAliasRE);
@@ -12136,7 +12151,7 @@ function genFor(el, state, altGen, altHelper) {
12136
12151
  !el.key) {
12137
12152
  state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
12138
12153
  `v-for should have explicit keys. ` +
12139
- `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
12154
+ `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
12140
12155
  }
12141
12156
  el.forProcessed = true; // avoid recursion
12142
12157
  return (`${altHelper || '_l'}((${exp}),` +
@@ -6,12 +6,12 @@ case `uname` in
6
6
  esac
7
7
 
8
8
  if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
9
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules/less/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules/less/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
10
10
  else
11
- export NODE_PATH="$NODE_PATH:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
11
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules/less/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules/less/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/less@4.1.3/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules:$NODE_PATH"
12
12
  fi
13
13
  if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/less@4.1.3/node_modules/less/bin/lessc" "$@"
14
+ exec "$basedir/node" "$basedir/../less/bin/lessc" "$@"
15
15
  else
16
- exec node "$basedir/../../../../node_modules/.pnpm/less@4.1.3/node_modules/less/bin/lessc" "$@"
16
+ exec node "$basedir/../less/bin/lessc" "$@"
17
17
  fi
@@ -6,12 +6,12 @@ case `uname` in
6
6
  esac
7
7
 
8
8
  if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
9
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
10
10
  else
11
- export NODE_PATH="$NODE_PATH:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
11
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/@babel+parser@7.19.4/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules:$NODE_PATH"
12
12
  fi
13
13
  if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/bin/babel-parser.js" "$@"
14
+ exec "$basedir/node" "$basedir/../@babel/parser/bin/babel-parser.js" "$@"
15
15
  else
16
- exec node "$basedir/../../../../node_modules/.pnpm/@babel+parser@7.19.4/node_modules/@babel/parser/bin/babel-parser.js" "$@"
16
+ exec node "$basedir/../@babel/parser/bin/babel-parser.js" "$@"
17
17
  fi
@@ -6,12 +6,12 @@ case `uname` in
6
6
  esac
7
7
 
8
8
  if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
9
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/sass@1.55.0/node_modules/sass/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/sass@1.55.0/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
10
10
  else
11
- export NODE_PATH="$NODE_PATH:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
11
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/sass@1.55.0/node_modules/sass/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/sass@1.55.0/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules:$NODE_PATH"
12
12
  fi
13
13
  if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/sass@1.55.0/node_modules/sass/sass.js" "$@"
14
+ exec "$basedir/node" "$basedir/../sass/sass.js" "$@"
15
15
  else
16
- exec node "$basedir/../../../../node_modules/.pnpm/sass@1.55.0/node_modules/sass/sass.js" "$@"
16
+ exec node "$basedir/../sass/sass.js" "$@"
17
17
  fi
@@ -6,12 +6,12 @@ case `uname` in
6
6
  esac
7
7
 
8
8
  if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
9
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
10
10
  else
11
- export NODE_PATH="$NODE_PATH:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules"
11
+ export NODE_PATH="/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/bin/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/stylus@0.58.1/node_modules:/Users/evan/Vue/vue/node_modules/.pnpm/node_modules:$NODE_PATH"
12
12
  fi
13
13
  if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/bin/stylus" "$@"
14
+ exec "$basedir/node" "$basedir/../stylus/bin/stylus" "$@"
15
15
  else
16
- exec node "$basedir/../../../../node_modules/.pnpm/stylus@0.58.1/node_modules/stylus/bin/stylus" "$@"
16
+ exec node "$basedir/../stylus/bin/stylus" "$@"
17
17
  fi
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "2.7.13",
3
+ "version": "2.7.15",
4
4
  "description": "compiler-sfc for Vue 2",
5
5
  "main": "dist/compiler-sfc.js",
6
6
  "types": "dist/compiler-sfc.d.ts",
@@ -39,7 +39,7 @@ import { walk } from 'estree-walker'
39
39
  import { RawSourceMap } from 'source-map'
40
40
  import { warnOnce } from './warn'
41
41
  import { isReservedTag } from 'web/util'
42
- import { bindRE, dirRE, onRE } from 'compiler/parser'
42
+ import { bindRE, dirRE, onRE, slotRE } from 'compiler/parser'
43
43
  import { parseText } from 'compiler/parser/text-parser'
44
44
  import { DEFAULT_FILENAME } from './parseComponent'
45
45
  import {
@@ -414,7 +414,10 @@ export function compileScript(
414
414
  }
415
415
 
416
416
  if (declId) {
417
- emitIdentifier = scriptSetup!.content.slice(declId.start!, declId.end!)
417
+ emitIdentifier =
418
+ declId.type === 'Identifier'
419
+ ? declId.name
420
+ : scriptSetup!.content.slice(declId.start!, declId.end!)
418
421
  }
419
422
 
420
423
  return true
@@ -907,11 +910,11 @@ export function compileScript(
907
910
  } else {
908
911
  let start = decl.start! + startOffset
909
912
  let end = decl.end! + startOffset
910
- if (i < total - 1) {
911
- // not the last one, locate the start of the next
913
+ if (i === 0) {
914
+ // first one, locate the start of the next
912
915
  end = node.declarations[i + 1].start! + startOffset
913
916
  } else {
914
- // last one, locate the end of the prev
917
+ // not first one, locate the end of the prev
915
918
  start = node.declarations[i - 1].end! + startOffset
916
919
  }
917
920
  s.remove(start, end)
@@ -1122,7 +1125,7 @@ export function compileScript(
1122
1125
  startOffset,
1123
1126
  `\nconst ${propsIdentifier} = __props${
1124
1127
  propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``
1125
- }\n`
1128
+ };\n`
1126
1129
  )
1127
1130
  }
1128
1131
  if (propsDestructureRestId) {
@@ -1130,7 +1133,7 @@ export function compileScript(
1130
1133
  startOffset,
1131
1134
  `\nconst ${propsDestructureRestId} = ${helper(
1132
1135
  `createPropsRestProxy`
1133
- )}(__props, ${JSON.stringify(Object.keys(propsDestructuredBindings))})\n`
1136
+ )}(__props, ${JSON.stringify(Object.keys(propsDestructuredBindings))});\n`
1134
1137
  )
1135
1138
  }
1136
1139
 
@@ -1804,6 +1807,8 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor, isTS: boolean) {
1804
1807
  if (dirRE.test(name)) {
1805
1808
  const baseName = onRE.test(name)
1806
1809
  ? 'on'
1810
+ : slotRE.test(name)
1811
+ ? 'slot'
1807
1812
  : bindRE.test(name)
1808
1813
  ? 'bind'
1809
1814
  : name.replace(dirRE, '')
@@ -1836,7 +1841,7 @@ function processExp(exp: string, isTS: boolean, dir?: string): string {
1836
1841
  if (dir === 'slot') {
1837
1842
  exp = `(${exp})=>{}`
1838
1843
  } else if (dir === 'on') {
1839
- exp = `()=>{${exp}}`
1844
+ exp = `()=>{return ${exp}}`
1840
1845
  } else if (dir === 'for') {
1841
1846
  const inMatch = exp.match(forAliasRE)
1842
1847
  if (inMatch) {
@@ -1,4 +1,4 @@
1
- // Vitest Snapshot v1
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`SFC analyze <script> bindings > auto name inference > basic 1`] = `
4
4
  "export default {
@@ -212,7 +212,7 @@ export default {
212
212
  props: propsModel,
213
213
  setup(__props) {
214
214
 
215
- const props = __props
215
+ const props = __props;
216
216
 
217
217
 
218
218
 
@@ -229,7 +229,7 @@ export default {
229
229
  props: {},
230
230
  setup(__props) {
231
231
 
232
- const props = __props
232
+ const props = __props;
233
233
 
234
234
 
235
235
  return { props, x }
@@ -245,7 +245,7 @@ exports[`SFC compile <script setup> > defineProps() 1`] = `
245
245
  },
246
246
  setup(__props) {
247
247
 
248
- const props = __props
248
+ const props = __props;
249
249
 
250
250
 
251
251
  const bar = 1
@@ -262,7 +262,7 @@ exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable
262
262
  emits: ['a'],
263
263
  setup(__props, { emit }) {
264
264
 
265
- const props = __props
265
+ const props = __props;
266
266
 
267
267
 
268
268
 
@@ -278,7 +278,7 @@ exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable
278
278
  emits: ['a'],
279
279
  setup(__props, { emit }) {
280
280
 
281
- const props = __props
281
+ const props = __props;
282
282
 
283
283
  const a = 1;
284
284
 
@@ -288,6 +288,22 @@ return { props, a, emit }
288
288
  }"
289
289
  `;
290
290
 
291
+ exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable declaration fix #6757 1`] = `
292
+ "export default {
293
+ props: ['item'],
294
+ emits: ['a'],
295
+ setup(__props, { emit }) {
296
+
297
+ const props = __props;
298
+
299
+ const a = 1;
300
+
301
+ return { a, props, emit }
302
+ }
303
+
304
+ }"
305
+ `;
306
+
291
307
  exports[`SFC compile <script setup> > dev mode import usage check > TS annotations 1`] = `
292
308
  "import { defineComponent as _defineComponent } from 'vue'
293
309
  import { Foo, Baz, Qux, Fred } from './x'
@@ -558,6 +574,22 @@ export default /*#__PURE__*/_defineComponent({
558
574
 
559
575
 
560
576
 
577
+ return { emit }
578
+ }
579
+
580
+ })"
581
+ `;
582
+
583
+ exports[`SFC compile <script setup> > with TypeScript > defineEmits w/ type (interface ts type) 1`] = `
584
+ "import { defineComponent as _defineComponent } from 'vue'
585
+ interface Emits { (e: 'foo'): void }
586
+
587
+ export default /*#__PURE__*/_defineComponent({
588
+ emits: ['foo'],
589
+ setup(__props, { emit }) {
590
+
591
+
592
+
561
593
  return { emit }
562
594
  }
563
595
 
@@ -803,7 +835,7 @@ export default /*#__PURE__*/_defineComponent({
803
835
  emits: ['a', 'b'],
804
836
  setup(__props, { emit }) {
805
837
 
806
- const props = __props
838
+ const props = __props;
807
839
 
808
840
 
809
841
 
@@ -892,7 +924,7 @@ const props = __props as {
892
924
  foo?: string
893
925
  bar?: number
894
926
  baz: boolean
895
- }
927
+ };
896
928
 
897
929
 
898
930
 
@@ -914,7 +946,7 @@ export default /*#__PURE__*/_defineComponent({
914
946
  },
915
947
  setup(__props: any) {
916
948
 
917
- const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number }
949
+ const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number };
918
950
 
919
951
 
920
952
 
@@ -1,4 +1,4 @@
1
- // Vitest Snapshot v1
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`CSS vars injection > codegen > <script> w/ default export 1`] = `
4
4
  "const __default__ = { setup() {} }
@@ -141,6 +141,21 @@ const myEmit = defineEmits(['foo', 'bar'])
141
141
  expect(content).toMatch(`emits: ['a'],`)
142
142
  })
143
143
 
144
+ // vuejs/core #6757
145
+ test('defineProps/defineEmits in multi-variable declaration fix #6757 ', () => {
146
+ const { content } = compile(`
147
+ <script setup>
148
+ const a = 1,
149
+ props = defineProps(['item']),
150
+ emit = defineEmits(['a']);
151
+ </script>
152
+ `)
153
+ assertCode(content)
154
+ expect(content).toMatch(`const a = 1;`) // test correct removal
155
+ expect(content).toMatch(`props: ['item'],`)
156
+ expect(content).toMatch(`emits: ['a'],`)
157
+ })
158
+
144
159
  test('defineProps/defineEmits in multi-variable declaration (full removal)', () => {
145
160
  const { content } = compile(`
146
161
  <script setup>
@@ -1081,6 +1096,19 @@ const emit = defineEmits(['a', 'b'])
1081
1096
  expect(content).toMatch(`emits: ["foo", "bar"]`)
1082
1097
  })
1083
1098
 
1099
+ // https://github.com/vuejs/core/issues/5393
1100
+ test('defineEmits w/ type (interface ts type)', () => {
1101
+ const { content } = compile(`
1102
+ <script setup lang="ts">
1103
+ interface Emits { (e: 'foo'): void }
1104
+ const emit: Emits = defineEmits(['foo'])
1105
+ </script>
1106
+ `)
1107
+ assertCode(content)
1108
+ expect(content).toMatch(`setup(__props, { emit }) {`)
1109
+ expect(content).toMatch(`emits: ['foo']`)
1110
+ })
1111
+
1084
1112
  test('runtime Enum', () => {
1085
1113
  const { content, bindings } = compile(
1086
1114
  `<script setup lang="ts">
@@ -1571,7 +1599,23 @@ describe('SFC analyze <script> bindings', () => {
1571
1599
  </script>
1572
1600
  <template>
1573
1601
  <div @click="$emit('update:a');"></div>
1574
- </tempalte>
1602
+ </template>
1603
+ `)
1604
+ })
1605
+
1606
+ // #12841
1607
+ test('should not error when performing ts expression check for v-slot destructured default value', () => {
1608
+ compile(`
1609
+ <script setup lang="ts">
1610
+ import FooComp from './Foo.vue'
1611
+ </script>
1612
+ <template>
1613
+ <FooComp>
1614
+ <template #bar="{ bar = { baz: '' } }">
1615
+ {{ bar.baz }}
1616
+ </template>
1617
+ </FooComp>
1618
+ </template>
1575
1619
  `)
1576
1620
  })
1577
1621
  })
@@ -259,7 +259,7 @@ export function genFor(
259
259
  state.warn(
260
260
  `<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
261
261
  `v-for should have explicit keys. ` +
262
- `See https://vuejs.org/guide/list.html#key for more info.`,
262
+ `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`,
263
263
  el.rawAttrsMap['v-for'],
264
264
  true /* tip */
265
265
  )
@@ -98,7 +98,7 @@ export function parseHTML(html, options: HTMLParserOptions) {
98
98
  }
99
99
  }
100
100
 
101
- // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
101
+ // https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
102
102
  if (conditionalComment.test(html)) {
103
103
  const conditionalEnd = html.indexOf(']>')
104
104
 
@@ -42,7 +42,7 @@ export const bindRE = /^:|^\.|^v-bind:/
42
42
  const propBindRE = /^\./
43
43
  const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g
44
44
 
45
- const slotRE = /^v-slot(:|$)|^#/
45
+ export const slotRE = /^v-slot(:|$)|^#/
46
46
 
47
47
  const lineBreakRE = /[\r\n]/
48
48
  const whitespaceRE = /[ \f\t\r\n]+/g
@@ -18,6 +18,7 @@ import {
18
18
  invokeWithErrorHandling
19
19
  } from '../util/index'
20
20
  import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
21
+ import { getCurrentScope } from 'v3/reactivity/effectScope'
21
22
  import { syncSetupProxy } from 'v3/apiSetup'
22
23
 
23
24
  export let activeInstance: any = null
@@ -398,7 +399,8 @@ export function callHook(
398
399
  ) {
399
400
  // #7573 disable dep collection when invoking lifecycle hooks
400
401
  pushTarget()
401
- const prev = currentInstance
402
+ const prevInst = currentInstance
403
+ const prevScope = getCurrentScope()
402
404
  setContext && setCurrentInstance(vm)
403
405
  const handlers = vm.$options[hook]
404
406
  const info = `${hook} hook`
@@ -410,6 +412,10 @@ export function callHook(
410
412
  if (vm._hasHookEvent) {
411
413
  vm.$emit('hook:' + hook)
412
414
  }
413
- setContext && setCurrentInstance(prev)
415
+ if (setContext) {
416
+ setCurrentInstance(prevInst)
417
+ prevScope && prevScope.on()
418
+ }
419
+
414
420
  popTarget()
415
421
  }
@@ -16,11 +16,10 @@ import {
16
16
  noop
17
17
  } from '../util/index'
18
18
  import { isReadonly, isRef, TrackOpTypes, TriggerOpTypes } from '../../v3'
19
- import { rawMap } from '../../v3/reactivity/reactive'
20
19
 
21
20
  const arrayKeys = Object.getOwnPropertyNames(arrayMethods)
22
21
 
23
- const NO_INIITIAL_VALUE = {}
22
+ const NO_INITIAL_VALUE = {}
24
23
 
25
24
  /**
26
25
  * In some cases we may want to disable observation inside a component's
@@ -80,7 +79,7 @@ export class Observer {
80
79
  const keys = Object.keys(value)
81
80
  for (let i = 0; i < keys.length; i++) {
82
81
  const key = keys[i]
83
- defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock)
82
+ defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock)
84
83
  }
85
84
  }
86
85
  }
@@ -116,7 +115,6 @@ export function observe(
116
115
  (isArray(value) || isPlainObject(value)) &&
117
116
  Object.isExtensible(value) &&
118
117
  !value.__v_skip /* ReactiveFlags.SKIP */ &&
119
- !rawMap.has(value) &&
120
118
  !isRef(value) &&
121
119
  !(value instanceof VNode)
122
120
  ) {
@@ -147,7 +145,7 @@ export function defineReactive(
147
145
  const setter = property && property.set
148
146
  if (
149
147
  (!getter || setter) &&
150
- (val === NO_INIITIAL_VALUE || arguments.length === 2)
148
+ (val === NO_INITIAL_VALUE || arguments.length === 2)
151
149
  ) {
152
150
  val = obj[key]
153
151
  }