@vue/compat 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.
@@ -132,7 +132,15 @@ const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,col
132
132
  'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
133
133
  'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
134
134
  'text,textPath,title,tspan,unknown,use,view';
135
+ /**
136
+ * Compiler only.
137
+ * Do NOT use in runtime code paths unless behind `true` flag.
138
+ */
135
139
  const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
140
+ /**
141
+ * Compiler only.
142
+ * Do NOT use in runtime code paths unless behind `true` flag.
143
+ */
136
144
  const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
137
145
 
138
146
  function looseCompareArrays(a, b) {
@@ -476,7 +484,7 @@ class ReactiveEffect {
476
484
  if (!this.active) {
477
485
  return this.fn();
478
486
  }
479
- if (!effectStack.includes(this)) {
487
+ if (!effectStack.length || !effectStack.includes(this)) {
480
488
  try {
481
489
  effectStack.push((activeEffect = this));
482
490
  enableTracking();
@@ -732,6 +740,9 @@ function createGetter(isReadonly = false, shallow = false) {
732
740
  else if (key === "__v_isReadonly" /* IS_READONLY */) {
733
741
  return isReadonly;
734
742
  }
743
+ else if (key === "__v_isShallow" /* IS_SHALLOW */) {
744
+ return shallow;
745
+ }
735
746
  else if (key === "__v_raw" /* RAW */ &&
736
747
  receiver ===
737
748
  (isReadonly
@@ -776,9 +787,14 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
776
787
  function createSetter(shallow = false) {
777
788
  return function set(target, key, value, receiver) {
778
789
  let oldValue = target[key];
790
+ if (isReadonly(oldValue) && isRef(oldValue)) {
791
+ return false;
792
+ }
779
793
  if (!shallow && !isReadonly(value)) {
780
- value = toRaw(value);
781
- oldValue = toRaw(oldValue);
794
+ if (!isShallow(value)) {
795
+ value = toRaw(value);
796
+ oldValue = toRaw(oldValue);
797
+ }
782
798
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
783
799
  oldValue.value = value;
784
800
  return true;
@@ -1165,7 +1181,7 @@ function getTargetType(value) {
1165
1181
  }
1166
1182
  function reactive(target) {
1167
1183
  // if trying to observe a readonly proxy, return the readonly version.
1168
- if (target && target["__v_isReadonly" /* IS_READONLY */]) {
1184
+ if (isReadonly(target)) {
1169
1185
  return target;
1170
1186
  }
1171
1187
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -1230,6 +1246,9 @@ function isReactive(value) {
1230
1246
  function isReadonly(value) {
1231
1247
  return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
1232
1248
  }
1249
+ function isShallow(value) {
1250
+ return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
1251
+ }
1233
1252
  function isProxy(value) {
1234
1253
  return isReactive(value) || isReadonly(value);
1235
1254
  }
@@ -1288,22 +1307,22 @@ function createRef(rawValue, shallow) {
1288
1307
  return new RefImpl(rawValue, shallow);
1289
1308
  }
1290
1309
  class RefImpl {
1291
- constructor(value, _shallow) {
1292
- this._shallow = _shallow;
1310
+ constructor(value, __v_isShallow) {
1311
+ this.__v_isShallow = __v_isShallow;
1293
1312
  this.dep = undefined;
1294
1313
  this.__v_isRef = true;
1295
- this._rawValue = _shallow ? value : toRaw(value);
1296
- this._value = _shallow ? value : toReactive(value);
1314
+ this._rawValue = __v_isShallow ? value : toRaw(value);
1315
+ this._value = __v_isShallow ? value : toReactive(value);
1297
1316
  }
1298
1317
  get value() {
1299
1318
  trackRefValue(this);
1300
1319
  return this._value;
1301
1320
  }
1302
1321
  set value(newVal) {
1303
- newVal = this._shallow ? newVal : toRaw(newVal);
1322
+ newVal = this.__v_isShallow ? newVal : toRaw(newVal);
1304
1323
  if (hasChanged(newVal, this._rawValue)) {
1305
1324
  this._rawValue = newVal;
1306
- this._value = this._shallow ? newVal : toReactive(newVal);
1325
+ this._value = this.__v_isShallow ? newVal : toReactive(newVal);
1307
1326
  triggerRefValue(this, newVal);
1308
1327
  }
1309
1328
  }
@@ -1386,22 +1405,23 @@ class ComputedRefImpl {
1386
1405
  constructor(getter, _setter, isReadonly, isSSR) {
1387
1406
  this._setter = _setter;
1388
1407
  this.dep = undefined;
1389
- this._dirty = true;
1390
1408
  this.__v_isRef = true;
1409
+ this._dirty = true;
1391
1410
  this.effect = new ReactiveEffect(getter, () => {
1392
1411
  if (!this._dirty) {
1393
1412
  this._dirty = true;
1394
1413
  triggerRefValue(this);
1395
1414
  }
1396
1415
  });
1397
- this.effect.active = !isSSR;
1416
+ this.effect.computed = this;
1417
+ this.effect.active = this._cacheable = !isSSR;
1398
1418
  this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1399
1419
  }
1400
1420
  get value() {
1401
1421
  // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1402
1422
  const self = toRaw(this);
1403
1423
  trackRefValue(self);
1404
- if (self._dirty) {
1424
+ if (self._dirty || !self._cacheable) {
1405
1425
  self._dirty = false;
1406
1426
  self._value = self.effect.run();
1407
1427
  }
@@ -1578,7 +1598,7 @@ const ErrorTypeStrings = {
1578
1598
  [12 /* FUNCTION_REF */]: 'ref function',
1579
1599
  [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
1580
1600
  [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
1581
- 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
1601
+ 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
1582
1602
  };
1583
1603
  function callWithErrorHandling(fn, instance, type, args) {
1584
1604
  let res;
@@ -2126,7 +2146,7 @@ const deprecationData = {
2126
2146
  ["CONFIG_DEVTOOLS" /* CONFIG_DEVTOOLS */]: {
2127
2147
  message: `config.devtools has been removed. To enable devtools for ` +
2128
2148
  `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
2129
- link: `https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags`
2149
+ link: `https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags`
2130
2150
  },
2131
2151
  ["CONFIG_KEY_CODES" /* CONFIG_KEY_CODES */]: {
2132
2152
  message: `config.keyCodes has been removed. ` +
@@ -2313,7 +2333,7 @@ const deprecationData = {
2313
2333
  (isArray(comp.props)
2314
2334
  ? comp.props.includes('modelValue')
2315
2335
  : hasOwn(comp.props, 'modelValue'))) {
2316
- return (`Component delcares "modelValue" prop, which is Vue 3 usage, but ` +
2336
+ return (`Component declares "modelValue" prop, which is Vue 3 usage, but ` +
2317
2337
  `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
2318
2338
  }
2319
2339
  return (`v-model usage on component has changed in Vue 3. Component that expects ` +
@@ -2543,6 +2563,7 @@ const compatModelEventPrefix = `onModelCompat:`;
2543
2563
  const warnedTypes = new WeakSet();
2544
2564
  function convertLegacyVModelProps(vnode) {
2545
2565
  const { type, shapeFlag, props, dynamicProps } = vnode;
2566
+ const comp = type;
2546
2567
  if (shapeFlag & 6 /* COMPONENT */ && props && 'modelValue' in props) {
2547
2568
  if (!isCompatEnabled("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */,
2548
2569
  // this is a special case where we want to use the vnode component's
@@ -2551,16 +2572,18 @@ function convertLegacyVModelProps(vnode) {
2551
2572
  { type })) {
2552
2573
  return;
2553
2574
  }
2554
- if (!warnedTypes.has(type)) {
2575
+ if (!warnedTypes.has(comp)) {
2555
2576
  pushWarningContext(vnode);
2556
- warnDeprecation("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */, { type }, type);
2577
+ warnDeprecation("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */, { type }, comp);
2557
2578
  popWarningContext();
2558
- warnedTypes.add(type);
2579
+ warnedTypes.add(comp);
2559
2580
  }
2560
2581
  // v3 compiled model code -> v2 compat props
2561
2582
  // modelValue -> value
2562
2583
  // onUpdate:modelValue -> onModelCompat:input
2563
- const { prop = 'value', event = 'input' } = type.model || {};
2584
+ const model = comp.model || {};
2585
+ applyModelFromMixins(model, comp.mixins);
2586
+ const { prop = 'value', event = 'input' } = model;
2564
2587
  if (prop !== 'modelValue') {
2565
2588
  props[prop] = props.modelValue;
2566
2589
  delete props.modelValue;
@@ -2573,6 +2596,16 @@ function convertLegacyVModelProps(vnode) {
2573
2596
  delete props['onUpdate:modelValue'];
2574
2597
  }
2575
2598
  }
2599
+ function applyModelFromMixins(model, mixins) {
2600
+ if (mixins) {
2601
+ mixins.forEach(m => {
2602
+ if (m.model)
2603
+ extend(model, m.model);
2604
+ if (m.mixins)
2605
+ applyModelFromMixins(model, m.mixins);
2606
+ });
2607
+ }
2608
+ }
2576
2609
  function compatModelEmit(instance, event, args) {
2577
2610
  if (!isCompatEnabled("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */, instance)) {
2578
2611
  return;
@@ -3575,7 +3608,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3575
3608
  if (instance) {
3576
3609
  // #2400
3577
3610
  // to support `app.use` plugins,
3578
- // fallback to appContext's `provides` if the intance is at root
3611
+ // fallback to appContext's `provides` if the instance is at root
3579
3612
  const provides = instance.parent == null
3580
3613
  ? instance.vnode.appContext && instance.vnode.appContext.provides
3581
3614
  : instance.parent.provides;
@@ -3641,7 +3674,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3641
3674
  let isMultiSource = false;
3642
3675
  if (isRef(source)) {
3643
3676
  getter = () => source.value;
3644
- forceTrigger = !!source._shallow;
3677
+ forceTrigger = isShallow(source);
3645
3678
  }
3646
3679
  else if (isReactive(source)) {
3647
3680
  getter = () => source;
@@ -4535,7 +4568,7 @@ function matches(pattern, name) {
4535
4568
  return pattern.some((p) => matches(p, name));
4536
4569
  }
4537
4570
  else if (isString(pattern)) {
4538
- return pattern.split(',').indexOf(name) > -1;
4571
+ return pattern.split(',').includes(name);
4539
4572
  }
4540
4573
  else if (pattern.test) {
4541
4574
  return pattern.test(name);
@@ -4803,7 +4836,7 @@ function applyOptions(instance) {
4803
4836
  warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4804
4837
  }
4805
4838
  ;
4806
- const c = computed({
4839
+ const c = computed$1({
4807
4840
  get,
4808
4841
  set
4809
4842
  });
@@ -5284,7 +5317,9 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
5284
5317
  // attrs point to the same object so it should already have been updated.
5285
5318
  if (attrs !== rawCurrentProps) {
5286
5319
  for (const key in attrs) {
5287
- if (!rawProps || !hasOwn(rawProps, key)) {
5320
+ if (!rawProps ||
5321
+ (!hasOwn(rawProps, key) &&
5322
+ (!hasOwn(rawProps, key + 'Native')))) {
5288
5323
  delete attrs[key];
5289
5324
  hasAttrsChanged = true;
5290
5325
  }
@@ -5922,7 +5957,7 @@ function createCompatVue(createApp, createSingletonApp) {
5922
5957
  return vm;
5923
5958
  }
5924
5959
  }
5925
- Vue.version = "3.2.27";
5960
+ Vue.version = `2.6.14-compat:${"3.2.28"}`;
5926
5961
  Vue.config = singletonApp.config;
5927
5962
  Vue.use = (p, ...options) => {
5928
5963
  if (p && isFunction(p.install)) {
@@ -6911,6 +6946,7 @@ function createHydrationFunctions(rendererInternals) {
6911
6946
  return [hydrate, hydrateNode];
6912
6947
  }
6913
6948
 
6949
+ /* eslint-disable no-restricted-globals */
6914
6950
  let supported;
6915
6951
  let perf;
6916
6952
  function startMeasure(instance, type) {
@@ -6938,7 +6974,6 @@ function isSupported() {
6938
6974
  if (supported !== undefined) {
6939
6975
  return supported;
6940
6976
  }
6941
- /* eslint-disable no-restricted-globals */
6942
6977
  if (typeof window !== 'undefined' && window.performance) {
6943
6978
  supported = true;
6944
6979
  perf = window.performance;
@@ -6946,7 +6981,6 @@ function isSupported() {
6946
6981
  else {
6947
6982
  supported = false;
6948
6983
  }
6949
- /* eslint-enable no-restricted-globals */
6950
6984
  return supported;
6951
6985
  }
6952
6986
 
@@ -9192,7 +9226,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
9192
9226
  shapeFlag: vnode.shapeFlag,
9193
9227
  // if the vnode is cloned with extra props, we can no longer assume its
9194
9228
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
9195
- // note: perserve flag for fragments since they use the flag for children
9229
+ // note: preserve flag for fragments since they use the flag for children
9196
9230
  // fast paths only.
9197
9231
  patchFlag: extraProps && vnode.type !== Fragment
9198
9232
  ? patchFlag === -1 // hoisted node
@@ -9357,7 +9391,8 @@ function mergeProps(...args) {
9357
9391
  else if (isOn(key)) {
9358
9392
  const existing = ret[key];
9359
9393
  const incoming = toMerge[key];
9360
- if (existing !== incoming &&
9394
+ if (incoming &&
9395
+ existing !== incoming &&
9361
9396
  !(isArray(existing) && existing.includes(incoming))) {
9362
9397
  ret[key] = existing
9363
9398
  ? [].concat(existing, incoming)
@@ -9633,7 +9668,7 @@ function legacyCheckKeyCodes(instance, eventKeyCode, key, builtInKeyCode, eventK
9633
9668
  }
9634
9669
  function isKeyNotMatch(expect, actual) {
9635
9670
  if (isArray(expect)) {
9636
- return expect.indexOf(actual) === -1;
9671
+ return !expect.includes(actual);
9637
9672
  }
9638
9673
  else {
9639
9674
  return expect !== actual;
@@ -9712,7 +9747,7 @@ function installCompatInstanceProperties(map) {
9712
9747
  extend(map, {
9713
9748
  // needed by many libs / render fns
9714
9749
  $vnode: i => i.vnode,
9715
- // inject addtional properties into $options for compat
9750
+ // inject additional properties into $options for compat
9716
9751
  // e.g. vuex needs this.$options.parent
9717
9752
  $options: i => {
9718
9753
  const res = extend({}, resolveMergedOptions(i));
@@ -10440,7 +10475,7 @@ function defineEmits() {
10440
10475
  * instance properties when it is accessed by a parent component via template
10441
10476
  * refs.
10442
10477
  *
10443
- * `<script setup>` components are closed by default - i.e. varaibles inside
10478
+ * `<script setup>` components are closed by default - i.e. variables inside
10444
10479
  * the `<script setup>` scope is not exposed to parent unless explicitly exposed
10445
10480
  * via `defineExpose`.
10446
10481
  *
@@ -10643,7 +10678,7 @@ function initCustomFormatter() {
10643
10678
  return [
10644
10679
  'div',
10645
10680
  {},
10646
- ['span', vueStyle, 'Reactive'],
10681
+ ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
10647
10682
  '<',
10648
10683
  formatValue(obj),
10649
10684
  `>${isReadonly(obj) ? ` (readonly)` : ``}`
@@ -10653,7 +10688,7 @@ function initCustomFormatter() {
10653
10688
  return [
10654
10689
  'div',
10655
10690
  {},
10656
- ['span', vueStyle, 'Readonly'],
10691
+ ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
10657
10692
  '<',
10658
10693
  formatValue(obj),
10659
10694
  '>'
@@ -10782,7 +10817,7 @@ function initCustomFormatter() {
10782
10817
  }
10783
10818
  }
10784
10819
  function genRefFlag(v) {
10785
- if (v._shallow) {
10820
+ if (isShallow(v)) {
10786
10821
  return `ShallowRef`;
10787
10822
  }
10788
10823
  if (v.effect) {
@@ -10826,7 +10861,7 @@ function isMemoSame(cached, memo) {
10826
10861
  }
10827
10862
 
10828
10863
  // Core API ------------------------------------------------------------------
10829
- const version = "3.2.27";
10864
+ const version = "3.2.28";
10830
10865
  /**
10831
10866
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10832
10867
  * @internal
@@ -11257,7 +11292,7 @@ function patchStopImmediatePropagation(e, value) {
11257
11292
  originalStop.call(e);
11258
11293
  e._stopped = true;
11259
11294
  };
11260
- return value.map(fn => (e) => !e._stopped && fn(e));
11295
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
11261
11296
  }
11262
11297
  else {
11263
11298
  return value;
@@ -12631,6 +12666,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12631
12666
  isProxy: isProxy,
12632
12667
  isReactive: isReactive,
12633
12668
  isReadonly: isReadonly,
12669
+ isShallow: isShallow,
12634
12670
  customRef: customRef,
12635
12671
  triggerRef: triggerRef,
12636
12672
  shallowRef: shallowRef,
@@ -12795,4 +12831,4 @@ Vue.compile = (() => {
12795
12831
  const { configureCompat: configureCompat$1 } = Vue;
12796
12832
 
12797
12833
  export default Vue;
12798
- export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed$1 as computed, configureCompat$1 as configureCompat, 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$1 as 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 };
12834
+ export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed$1 as computed, configureCompat$1 as configureCompat, 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$1 as 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 };