@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.
@@ -230,8 +230,20 @@ const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,col
230
230
  'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
231
231
  'text,textPath,title,tspan,unknown,use,view';
232
232
  const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
233
+ /**
234
+ * Compiler only.
235
+ * Do NOT use in runtime code paths unless behind `false` flag.
236
+ */
233
237
  const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
238
+ /**
239
+ * Compiler only.
240
+ * Do NOT use in runtime code paths unless behind `false` flag.
241
+ */
234
242
  const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
243
+ /**
244
+ * Compiler only.
245
+ * Do NOT use in runtime code paths unless behind `false` flag.
246
+ */
235
247
  const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
236
248
 
237
249
  const escapeRE = /["'&<>]/;
@@ -603,7 +615,7 @@ class ReactiveEffect {
603
615
  if (!this.active) {
604
616
  return this.fn();
605
617
  }
606
- if (!effectStack.includes(this)) {
618
+ if (!effectStack.length || !effectStack.includes(this)) {
607
619
  try {
608
620
  effectStack.push((activeEffect = this));
609
621
  enableTracking();
@@ -847,6 +859,9 @@ function createGetter(isReadonly = false, shallow = false) {
847
859
  else if (key === "__v_isReadonly" /* IS_READONLY */) {
848
860
  return isReadonly;
849
861
  }
862
+ else if (key === "__v_isShallow" /* IS_SHALLOW */) {
863
+ return shallow;
864
+ }
850
865
  else if (key === "__v_raw" /* RAW */ &&
851
866
  receiver ===
852
867
  (isReadonly
@@ -891,9 +906,14 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
891
906
  function createSetter(shallow = false) {
892
907
  return function set(target, key, value, receiver) {
893
908
  let oldValue = target[key];
909
+ if (isReadonly(oldValue) && isRef(oldValue)) {
910
+ return false;
911
+ }
894
912
  if (!shallow && !isReadonly(value)) {
895
- value = toRaw(value);
896
- oldValue = toRaw(oldValue);
913
+ if (!isShallow(value)) {
914
+ value = toRaw(value);
915
+ oldValue = toRaw(oldValue);
916
+ }
897
917
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
898
918
  oldValue.value = value;
899
919
  return true;
@@ -1249,7 +1269,7 @@ function getTargetType(value) {
1249
1269
  }
1250
1270
  function reactive(target) {
1251
1271
  // if trying to observe a readonly proxy, return the readonly version.
1252
- if (target && target["__v_isReadonly" /* IS_READONLY */]) {
1272
+ if (isReadonly(target)) {
1253
1273
  return target;
1254
1274
  }
1255
1275
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -1311,6 +1331,9 @@ function isReactive(value) {
1311
1331
  function isReadonly(value) {
1312
1332
  return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
1313
1333
  }
1334
+ function isShallow(value) {
1335
+ return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
1336
+ }
1314
1337
  function isProxy(value) {
1315
1338
  return isReactive(value) || isReadonly(value);
1316
1339
  }
@@ -1360,22 +1383,22 @@ function createRef(rawValue, shallow) {
1360
1383
  return new RefImpl(rawValue, shallow);
1361
1384
  }
1362
1385
  class RefImpl {
1363
- constructor(value, _shallow) {
1364
- this._shallow = _shallow;
1386
+ constructor(value, __v_isShallow) {
1387
+ this.__v_isShallow = __v_isShallow;
1365
1388
  this.dep = undefined;
1366
1389
  this.__v_isRef = true;
1367
- this._rawValue = _shallow ? value : toRaw(value);
1368
- this._value = _shallow ? value : toReactive(value);
1390
+ this._rawValue = __v_isShallow ? value : toRaw(value);
1391
+ this._value = __v_isShallow ? value : toReactive(value);
1369
1392
  }
1370
1393
  get value() {
1371
1394
  trackRefValue(this);
1372
1395
  return this._value;
1373
1396
  }
1374
1397
  set value(newVal) {
1375
- newVal = this._shallow ? newVal : toRaw(newVal);
1398
+ newVal = this.__v_isShallow ? newVal : toRaw(newVal);
1376
1399
  if (hasChanged(newVal, this._rawValue)) {
1377
1400
  this._rawValue = newVal;
1378
- this._value = this._shallow ? newVal : toReactive(newVal);
1401
+ this._value = this.__v_isShallow ? newVal : toReactive(newVal);
1379
1402
  triggerRefValue(this);
1380
1403
  }
1381
1404
  }
@@ -1455,22 +1478,23 @@ class ComputedRefImpl {
1455
1478
  constructor(getter, _setter, isReadonly, isSSR) {
1456
1479
  this._setter = _setter;
1457
1480
  this.dep = undefined;
1458
- this._dirty = true;
1459
1481
  this.__v_isRef = true;
1482
+ this._dirty = true;
1460
1483
  this.effect = new ReactiveEffect(getter, () => {
1461
1484
  if (!this._dirty) {
1462
1485
  this._dirty = true;
1463
1486
  triggerRefValue(this);
1464
1487
  }
1465
1488
  });
1466
- this.effect.active = !isSSR;
1489
+ this.effect.computed = this;
1490
+ this.effect.active = this._cacheable = !isSSR;
1467
1491
  this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1468
1492
  }
1469
1493
  get value() {
1470
1494
  // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1471
1495
  const self = toRaw(this);
1472
1496
  trackRefValue(self);
1473
- if (self._dirty) {
1497
+ if (self._dirty || !self._cacheable) {
1474
1498
  self._dirty = false;
1475
1499
  self._value = self.effect.run();
1476
1500
  }
@@ -1996,6 +2020,7 @@ function emit(instance, event, args) {
1996
2020
  const compatModelEventPrefix = `onModelCompat:`;
1997
2021
  function convertLegacyVModelProps(vnode) {
1998
2022
  const { type, shapeFlag, props, dynamicProps } = vnode;
2023
+ const comp = type;
1999
2024
  if (shapeFlag & 6 /* COMPONENT */ && props && 'modelValue' in props) {
2000
2025
  if (!isCompatEnabled("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */,
2001
2026
  // this is a special case where we want to use the vnode component's
@@ -2007,7 +2032,9 @@ function convertLegacyVModelProps(vnode) {
2007
2032
  // v3 compiled model code -> v2 compat props
2008
2033
  // modelValue -> value
2009
2034
  // onUpdate:modelValue -> onModelCompat:input
2010
- const { prop = 'value', event = 'input' } = type.model || {};
2035
+ const model = comp.model || {};
2036
+ applyModelFromMixins(model, comp.mixins);
2037
+ const { prop = 'value', event = 'input' } = model;
2011
2038
  if (prop !== 'modelValue') {
2012
2039
  props[prop] = props.modelValue;
2013
2040
  delete props.modelValue;
@@ -2020,6 +2047,16 @@ function convertLegacyVModelProps(vnode) {
2020
2047
  delete props['onUpdate:modelValue'];
2021
2048
  }
2022
2049
  }
2050
+ function applyModelFromMixins(model, mixins) {
2051
+ if (mixins) {
2052
+ mixins.forEach(m => {
2053
+ if (m.model)
2054
+ extend(model, m.model);
2055
+ if (m.mixins)
2056
+ applyModelFromMixins(model, m.mixins);
2057
+ });
2058
+ }
2059
+ }
2023
2060
  function compatModelEmit(instance, event, args) {
2024
2061
  if (!isCompatEnabled("COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */, instance)) {
2025
2062
  return;
@@ -2853,7 +2890,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
2853
2890
  if (instance) {
2854
2891
  // #2400
2855
2892
  // to support `app.use` plugins,
2856
- // fallback to appContext's `provides` if the intance is at root
2893
+ // fallback to appContext's `provides` if the instance is at root
2857
2894
  const provides = instance.parent == null
2858
2895
  ? instance.vnode.appContext && instance.vnode.appContext.provides
2859
2896
  : instance.parent.provides;
@@ -2893,7 +2930,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
2893
2930
  let isMultiSource = false;
2894
2931
  if (isRef(source)) {
2895
2932
  getter = () => source.value;
2896
- forceTrigger = !!source._shallow;
2933
+ forceTrigger = isShallow(source);
2897
2934
  }
2898
2935
  else if (isReactive(source)) {
2899
2936
  getter = () => source;
@@ -3766,7 +3803,7 @@ function matches(pattern, name) {
3766
3803
  return pattern.some((p) => matches(p, name));
3767
3804
  }
3768
3805
  else if (isString(pattern)) {
3769
- return pattern.split(',').indexOf(name) > -1;
3806
+ return pattern.split(',').includes(name);
3770
3807
  }
3771
3808
  else if (pattern.test) {
3772
3809
  return pattern.test(name);
@@ -3962,7 +3999,7 @@ function applyOptions(instance) {
3962
3999
  const set = !isFunction(opt) && isFunction(opt.set)
3963
4000
  ? opt.set.bind(publicThis)
3964
4001
  : NOOP;
3965
- const c = computed({
4002
+ const c = computed$1({
3966
4003
  get,
3967
4004
  set
3968
4005
  });
@@ -4412,7 +4449,9 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4412
4449
  // attrs point to the same object so it should already have been updated.
4413
4450
  if (attrs !== rawCurrentProps) {
4414
4451
  for (const key in attrs) {
4415
- if (!rawProps || !hasOwn(rawProps, key)) {
4452
+ if (!rawProps ||
4453
+ (!hasOwn(rawProps, key) &&
4454
+ (!hasOwn(rawProps, key + 'Native')))) {
4416
4455
  delete attrs[key];
4417
4456
  hasAttrsChanged = true;
4418
4457
  }
@@ -4856,7 +4895,7 @@ function createCompatVue(createApp, createSingletonApp) {
4856
4895
  return vm;
4857
4896
  }
4858
4897
  }
4859
- Vue.version = "3.2.27";
4898
+ Vue.version = `2.6.14-compat:${"3.2.28"}`;
4860
4899
  Vue.config = singletonApp.config;
4861
4900
  Vue.use = (p, ...options) => {
4862
4901
  if (p && isFunction(p.install)) {
@@ -7748,7 +7787,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7748
7787
  shapeFlag: vnode.shapeFlag,
7749
7788
  // if the vnode is cloned with extra props, we can no longer assume its
7750
7789
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7751
- // note: perserve flag for fragments since they use the flag for children
7790
+ // note: preserve flag for fragments since they use the flag for children
7752
7791
  // fast paths only.
7753
7792
  patchFlag: extraProps && vnode.type !== Fragment
7754
7793
  ? patchFlag === -1 // hoisted node
@@ -7902,7 +7941,8 @@ function mergeProps(...args) {
7902
7941
  else if (isOn(key)) {
7903
7942
  const existing = ret[key];
7904
7943
  const incoming = toMerge[key];
7905
- if (existing !== incoming &&
7944
+ if (incoming &&
7945
+ existing !== incoming &&
7906
7946
  !(isArray(existing) && existing.includes(incoming))) {
7907
7947
  ret[key] = existing
7908
7948
  ? [].concat(existing, incoming)
@@ -8164,7 +8204,7 @@ function legacyCheckKeyCodes(instance, eventKeyCode, key, builtInKeyCode, eventK
8164
8204
  }
8165
8205
  function isKeyNotMatch(expect, actual) {
8166
8206
  if (isArray(expect)) {
8167
- return expect.indexOf(actual) === -1;
8207
+ return !expect.includes(actual);
8168
8208
  }
8169
8209
  else {
8170
8210
  return expect !== actual;
@@ -8243,7 +8283,7 @@ function installCompatInstanceProperties(map) {
8243
8283
  extend(map, {
8244
8284
  // needed by many libs / render fns
8245
8285
  $vnode: i => i.vnode,
8246
- // inject addtional properties into $options for compat
8286
+ // inject additional properties into $options for compat
8247
8287
  // e.g. vuex needs this.$options.parent
8248
8288
  $options: i => {
8249
8289
  const res = extend({}, resolveMergedOptions(i));
@@ -8771,7 +8811,7 @@ function defineEmits() {
8771
8811
  * instance properties when it is accessed by a parent component via template
8772
8812
  * refs.
8773
8813
  *
8774
- * `<script setup>` components are closed by default - i.e. varaibles inside
8814
+ * `<script setup>` components are closed by default - i.e. variables inside
8775
8815
  * the `<script setup>` scope is not exposed to parent unless explicitly exposed
8776
8816
  * via `defineExpose`.
8777
8817
  *
@@ -8960,7 +9000,7 @@ function isMemoSame(cached, memo) {
8960
9000
  }
8961
9001
 
8962
9002
  // Core API ------------------------------------------------------------------
8963
- const version = "3.2.27";
9003
+ const version = "3.2.28";
8964
9004
  const _ssrUtils = {
8965
9005
  createComponentInstance,
8966
9006
  setupComponent,
@@ -9394,7 +9434,7 @@ function patchStopImmediatePropagation(e, value) {
9394
9434
  originalStop.call(e);
9395
9435
  e._stopped = true;
9396
9436
  };
9397
- return value.map(fn => (e) => !e._stopped && fn(e));
9437
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
9398
9438
  }
9399
9439
  else {
9400
9440
  return value;
@@ -10646,6 +10686,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10646
10686
  isProxy: isProxy,
10647
10687
  isReactive: isReactive,
10648
10688
  isReadonly: isReadonly,
10689
+ isShallow: isShallow,
10649
10690
  customRef: customRef,
10650
10691
  triggerRef: triggerRef,
10651
10692
  shallowRef: shallowRef,
@@ -11865,7 +11906,7 @@ function parseAttributes(context, type) {
11865
11906
  }
11866
11907
  const attr = parseAttribute(context, attributeNames);
11867
11908
  // Trim whitespace between class
11868
- // https://github.com/vuejs/vue-next/issues/4251
11909
+ // https://github.com/vuejs/core/issues/4251
11869
11910
  if (attr.type === 6 /* ATTRIBUTE */ &&
11870
11911
  attr.value &&
11871
11912
  attr.name === 'class') {
@@ -12098,7 +12139,7 @@ function parseTextData(context, length, mode) {
12098
12139
  advanceBy(context, length);
12099
12140
  if (mode === 2 /* RAWTEXT */ ||
12100
12141
  mode === 3 /* CDATA */ ||
12101
- rawText.indexOf('&') === -1) {
12142
+ !rawText.includes('&')) {
12102
12143
  return rawText;
12103
12144
  }
12104
12145
  else {
@@ -13804,7 +13845,7 @@ function isReferenced(node, parent, grandparent) {
13804
13845
  // no: NODE.target
13805
13846
  case 'MetaProperty':
13806
13847
  return false;
13807
- // yes: type X = { somePropert: NODE }
13848
+ // yes: type X = { someProperty: NODE }
13808
13849
  // no: type X = { NODE: OtherType }
13809
13850
  case 'ObjectTypeProperty':
13810
13851
  return parent.key !== node;
@@ -14295,6 +14336,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
14295
14336
  const renderExp = createCallExpression(helper(RENDER_LIST), [
14296
14337
  forNode.source
14297
14338
  ]);
14339
+ const isTemplate = isTemplateNode(node);
14298
14340
  const memo = findDir(node, 'memo');
14299
14341
  const keyProp = findProp(node, `key`);
14300
14342
  const keyExp = keyProp &&
@@ -14302,15 +14344,17 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
14302
14344
  ? createSimpleExpression(keyProp.value.content, true)
14303
14345
  : keyProp.exp);
14304
14346
  const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
14305
- if (context.prefixIdentifiers &&
14306
- keyProperty &&
14307
- keyProp.type !== 6 /* ATTRIBUTE */) {
14308
- // #2085 process :key expression needs to be processed in order for it
14309
- // to behave consistently for <template v-for> and <div v-for>.
14310
- // In the case of `<template v-for>`, the node is discarded and never
14311
- // traversed so its key expression won't be processed by the normal
14312
- // transforms.
14313
- keyProperty.value = processExpression(keyProperty.value, context);
14347
+ if (isTemplate) {
14348
+ // #2085 / #5288 process :key and v-memo expressions need to be
14349
+ // processed on `<template v-for>`. In this case the node is discarded
14350
+ // and never traversed so its binding expressions won't be processed
14351
+ // by the normal transforms.
14352
+ if (memo) {
14353
+ memo.exp = processExpression(memo.exp, context);
14354
+ }
14355
+ if (keyProperty && keyProp.type !== 6 /* ATTRIBUTE */) {
14356
+ keyProperty.value = processExpression(keyProperty.value, context);
14357
+ }
14314
14358
  }
14315
14359
  const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
14316
14360
  forNode.source.constType > 0 /* NOT_CONSTANT */;
@@ -14324,7 +14368,6 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
14324
14368
  return () => {
14325
14369
  // finish the codegen now that all children have been traversed
14326
14370
  let childBlock;
14327
- const isTemplate = isTemplateNode(node);
14328
14371
  const { children } = forNode;
14329
14372
  // check <template v-for> key placement
14330
14373
  if (isTemplate) {