vue 3.2.27 → 3.2.28

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.
@@ -206,8 +206,20 @@ const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,col
206
206
  'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
207
207
  'text,textPath,title,tspan,unknown,use,view';
208
208
  const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
209
+ /**
210
+ * Compiler only.
211
+ * Do NOT use in runtime code paths unless behind `true` flag.
212
+ */
209
213
  const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
214
+ /**
215
+ * Compiler only.
216
+ * Do NOT use in runtime code paths unless behind `true` flag.
217
+ */
210
218
  const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
219
+ /**
220
+ * Compiler only.
221
+ * Do NOT use in runtime code paths unless behind `true` flag.
222
+ */
211
223
  const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
212
224
 
213
225
  function looseCompareArrays(a, b) {
@@ -551,7 +563,7 @@ class ReactiveEffect {
551
563
  if (!this.active) {
552
564
  return this.fn();
553
565
  }
554
- if (!effectStack.includes(this)) {
566
+ if (!effectStack.length || !effectStack.includes(this)) {
555
567
  try {
556
568
  effectStack.push((activeEffect = this));
557
569
  enableTracking();
@@ -807,6 +819,9 @@ function createGetter(isReadonly = false, shallow = false) {
807
819
  else if (key === "__v_isReadonly" /* IS_READONLY */) {
808
820
  return isReadonly;
809
821
  }
822
+ else if (key === "__v_isShallow" /* IS_SHALLOW */) {
823
+ return shallow;
824
+ }
810
825
  else if (key === "__v_raw" /* RAW */ &&
811
826
  receiver ===
812
827
  (isReadonly
@@ -851,9 +866,14 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
851
866
  function createSetter(shallow = false) {
852
867
  return function set(target, key, value, receiver) {
853
868
  let oldValue = target[key];
869
+ if (isReadonly(oldValue) && isRef(oldValue)) {
870
+ return false;
871
+ }
854
872
  if (!shallow && !isReadonly(value)) {
855
- value = toRaw(value);
856
- oldValue = toRaw(oldValue);
873
+ if (!isShallow(value)) {
874
+ value = toRaw(value);
875
+ oldValue = toRaw(oldValue);
876
+ }
857
877
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
858
878
  oldValue.value = value;
859
879
  return true;
@@ -1240,7 +1260,7 @@ function getTargetType(value) {
1240
1260
  }
1241
1261
  function reactive(target) {
1242
1262
  // if trying to observe a readonly proxy, return the readonly version.
1243
- if (target && target["__v_isReadonly" /* IS_READONLY */]) {
1263
+ if (isReadonly(target)) {
1244
1264
  return target;
1245
1265
  }
1246
1266
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -1305,6 +1325,9 @@ function isReactive(value) {
1305
1325
  function isReadonly(value) {
1306
1326
  return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
1307
1327
  }
1328
+ function isShallow(value) {
1329
+ return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
1330
+ }
1308
1331
  function isProxy(value) {
1309
1332
  return isReactive(value) || isReadonly(value);
1310
1333
  }
@@ -1363,22 +1386,22 @@ function createRef(rawValue, shallow) {
1363
1386
  return new RefImpl(rawValue, shallow);
1364
1387
  }
1365
1388
  class RefImpl {
1366
- constructor(value, _shallow) {
1367
- this._shallow = _shallow;
1389
+ constructor(value, __v_isShallow) {
1390
+ this.__v_isShallow = __v_isShallow;
1368
1391
  this.dep = undefined;
1369
1392
  this.__v_isRef = true;
1370
- this._rawValue = _shallow ? value : toRaw(value);
1371
- this._value = _shallow ? value : toReactive(value);
1393
+ this._rawValue = __v_isShallow ? value : toRaw(value);
1394
+ this._value = __v_isShallow ? value : toReactive(value);
1372
1395
  }
1373
1396
  get value() {
1374
1397
  trackRefValue(this);
1375
1398
  return this._value;
1376
1399
  }
1377
1400
  set value(newVal) {
1378
- newVal = this._shallow ? newVal : toRaw(newVal);
1401
+ newVal = this.__v_isShallow ? newVal : toRaw(newVal);
1379
1402
  if (hasChanged(newVal, this._rawValue)) {
1380
1403
  this._rawValue = newVal;
1381
- this._value = this._shallow ? newVal : toReactive(newVal);
1404
+ this._value = this.__v_isShallow ? newVal : toReactive(newVal);
1382
1405
  triggerRefValue(this, newVal);
1383
1406
  }
1384
1407
  }
@@ -1461,22 +1484,23 @@ class ComputedRefImpl {
1461
1484
  constructor(getter, _setter, isReadonly, isSSR) {
1462
1485
  this._setter = _setter;
1463
1486
  this.dep = undefined;
1464
- this._dirty = true;
1465
1487
  this.__v_isRef = true;
1488
+ this._dirty = true;
1466
1489
  this.effect = new ReactiveEffect(getter, () => {
1467
1490
  if (!this._dirty) {
1468
1491
  this._dirty = true;
1469
1492
  triggerRefValue(this);
1470
1493
  }
1471
1494
  });
1472
- this.effect.active = !isSSR;
1495
+ this.effect.computed = this;
1496
+ this.effect.active = this._cacheable = !isSSR;
1473
1497
  this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1474
1498
  }
1475
1499
  get value() {
1476
1500
  // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1477
1501
  const self = toRaw(this);
1478
1502
  trackRefValue(self);
1479
- if (self._dirty) {
1503
+ if (self._dirty || !self._cacheable) {
1480
1504
  self._dirty = false;
1481
1505
  self._value = self.effect.run();
1482
1506
  }
@@ -1653,7 +1677,7 @@ const ErrorTypeStrings = {
1653
1677
  [12 /* FUNCTION_REF */]: 'ref function',
1654
1678
  [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
1655
1679
  [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
1656
- 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
1680
+ 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
1657
1681
  };
1658
1682
  function callWithErrorHandling(fn, instance, type, args) {
1659
1683
  let res;
@@ -3115,7 +3139,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3115
3139
  if (instance) {
3116
3140
  // #2400
3117
3141
  // to support `app.use` plugins,
3118
- // fallback to appContext's `provides` if the intance is at root
3142
+ // fallback to appContext's `provides` if the instance is at root
3119
3143
  const provides = instance.parent == null
3120
3144
  ? instance.vnode.appContext && instance.vnode.appContext.provides
3121
3145
  : instance.parent.provides;
@@ -3181,7 +3205,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3181
3205
  let isMultiSource = false;
3182
3206
  if (isRef(source)) {
3183
3207
  getter = () => source.value;
3184
- forceTrigger = !!source._shallow;
3208
+ forceTrigger = isShallow(source);
3185
3209
  }
3186
3210
  else if (isReactive(source)) {
3187
3211
  getter = () => source;
@@ -4056,7 +4080,7 @@ function matches(pattern, name) {
4056
4080
  return pattern.some((p) => matches(p, name));
4057
4081
  }
4058
4082
  else if (isString(pattern)) {
4059
- return pattern.split(',').indexOf(name) > -1;
4083
+ return pattern.split(',').includes(name);
4060
4084
  }
4061
4085
  else if (pattern.test) {
4062
4086
  return pattern.test(name);
@@ -4309,7 +4333,7 @@ function applyOptions(instance) {
4309
4333
  warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4310
4334
  }
4311
4335
  ;
4312
- const c = computed({
4336
+ const c = computed$1({
4313
4337
  get,
4314
4338
  set
4315
4339
  });
@@ -4708,7 +4732,9 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4708
4732
  // attrs point to the same object so it should already have been updated.
4709
4733
  if (attrs !== rawCurrentProps) {
4710
4734
  for (const key in attrs) {
4711
- if (!rawProps || !hasOwn(rawProps, key)) {
4735
+ if (!rawProps ||
4736
+ (!hasOwn(rawProps, key) &&
4737
+ (!false ))) {
4712
4738
  delete attrs[key];
4713
4739
  hasAttrsChanged = true;
4714
4740
  }
@@ -5804,6 +5830,7 @@ function createHydrationFunctions(rendererInternals) {
5804
5830
  return [hydrate, hydrateNode];
5805
5831
  }
5806
5832
 
5833
+ /* eslint-disable no-restricted-globals */
5807
5834
  let supported;
5808
5835
  let perf;
5809
5836
  function startMeasure(instance, type) {
@@ -5831,7 +5858,6 @@ function isSupported() {
5831
5858
  if (supported !== undefined) {
5832
5859
  return supported;
5833
5860
  }
5834
- /* eslint-disable no-restricted-globals */
5835
5861
  if (typeof window !== 'undefined' && window.performance) {
5836
5862
  supported = true;
5837
5863
  perf = window.performance;
@@ -5839,7 +5865,6 @@ function isSupported() {
5839
5865
  else {
5840
5866
  supported = false;
5841
5867
  }
5842
- /* eslint-enable no-restricted-globals */
5843
5868
  return supported;
5844
5869
  }
5845
5870
 
@@ -7716,7 +7741,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7716
7741
  shapeFlag: vnode.shapeFlag,
7717
7742
  // if the vnode is cloned with extra props, we can no longer assume its
7718
7743
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7719
- // note: perserve flag for fragments since they use the flag for children
7744
+ // note: preserve flag for fragments since they use the flag for children
7720
7745
  // fast paths only.
7721
7746
  patchFlag: extraProps && vnode.type !== Fragment
7722
7747
  ? patchFlag === -1 // hoisted node
@@ -7878,7 +7903,8 @@ function mergeProps(...args) {
7878
7903
  else if (isOn(key)) {
7879
7904
  const existing = ret[key];
7880
7905
  const incoming = toMerge[key];
7881
- if (existing !== incoming &&
7906
+ if (incoming &&
7907
+ existing !== incoming &&
7882
7908
  !(isArray(existing) && existing.includes(incoming))) {
7883
7909
  ret[key] = existing
7884
7910
  ? [].concat(existing, incoming)
@@ -8698,7 +8724,7 @@ function defineEmits() {
8698
8724
  * instance properties when it is accessed by a parent component via template
8699
8725
  * refs.
8700
8726
  *
8701
- * `<script setup>` components are closed by default - i.e. varaibles inside
8727
+ * `<script setup>` components are closed by default - i.e. variables inside
8702
8728
  * the `<script setup>` scope is not exposed to parent unless explicitly exposed
8703
8729
  * via `defineExpose`.
8704
8730
  *
@@ -8901,7 +8927,7 @@ function initCustomFormatter() {
8901
8927
  return [
8902
8928
  'div',
8903
8929
  {},
8904
- ['span', vueStyle, 'Reactive'],
8930
+ ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
8905
8931
  '<',
8906
8932
  formatValue(obj),
8907
8933
  `>${isReadonly(obj) ? ` (readonly)` : ``}`
@@ -8911,7 +8937,7 @@ function initCustomFormatter() {
8911
8937
  return [
8912
8938
  'div',
8913
8939
  {},
8914
- ['span', vueStyle, 'Readonly'],
8940
+ ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
8915
8941
  '<',
8916
8942
  formatValue(obj),
8917
8943
  '>'
@@ -9040,7 +9066,7 @@ function initCustomFormatter() {
9040
9066
  }
9041
9067
  }
9042
9068
  function genRefFlag(v) {
9043
- if (v._shallow) {
9069
+ if (isShallow(v)) {
9044
9070
  return `ShallowRef`;
9045
9071
  }
9046
9072
  if (v.effect) {
@@ -9084,7 +9110,7 @@ function isMemoSame(cached, memo) {
9084
9110
  }
9085
9111
 
9086
9112
  // Core API ------------------------------------------------------------------
9087
- const version = "3.2.27";
9113
+ const version = "3.2.28";
9088
9114
  /**
9089
9115
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9090
9116
  * @internal
@@ -9471,7 +9497,7 @@ function patchStopImmediatePropagation(e, value) {
9471
9497
  originalStop.call(e);
9472
9498
  e._stopped = true;
9473
9499
  };
9474
- return value.map(fn => (e) => !e._stopped && fn(e));
9500
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
9475
9501
  }
9476
9502
  else {
9477
9503
  return value;
@@ -10760,6 +10786,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10760
10786
  isProxy: isProxy,
10761
10787
  isReactive: isReactive,
10762
10788
  isReadonly: isReadonly,
10789
+ isShallow: isShallow,
10763
10790
  customRef: customRef,
10764
10791
  triggerRef: triggerRef,
10765
10792
  shallowRef: shallowRef,
@@ -12037,7 +12064,7 @@ function parseAttributes(context, type) {
12037
12064
  }
12038
12065
  const attr = parseAttribute(context, attributeNames);
12039
12066
  // Trim whitespace between class
12040
- // https://github.com/vuejs/vue-next/issues/4251
12067
+ // https://github.com/vuejs/core/issues/4251
12041
12068
  if (attr.type === 6 /* ATTRIBUTE */ &&
12042
12069
  attr.value &&
12043
12070
  attr.name === 'class') {
@@ -12262,7 +12289,7 @@ function parseTextData(context, length, mode) {
12262
12289
  advanceBy(context, length);
12263
12290
  if (mode === 2 /* RAWTEXT */ ||
12264
12291
  mode === 3 /* CDATA */ ||
12265
- rawText.indexOf('&') === -1) {
12292
+ !rawText.includes('&')) {
12266
12293
  return rawText;
12267
12294
  }
12268
12295
  else {
@@ -13767,6 +13794,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
13767
13794
  const renderExp = createCallExpression(helper(RENDER_LIST), [
13768
13795
  forNode.source
13769
13796
  ]);
13797
+ const isTemplate = isTemplateNode(node);
13770
13798
  const memo = findDir(node, 'memo');
13771
13799
  const keyProp = findProp(node, `key`);
13772
13800
  const keyExp = keyProp &&
@@ -13786,7 +13814,6 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
13786
13814
  return () => {
13787
13815
  // finish the codegen now that all children have been traversed
13788
13816
  let childBlock;
13789
- const isTemplate = isTemplateNode(node);
13790
13817
  const { children } = forNode;
13791
13818
  // check <template v-for> key placement
13792
13819
  if (isTemplate) {
@@ -15727,4 +15754,4 @@ function compileToFunction(template, options) {
15727
15754
  }
15728
15755
  registerRuntimeCompiler(compileToFunction);
15729
15756
 
15730
- export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
15757
+ export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };