@vue/compat 3.2.30 → 3.2.33

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.
@@ -486,8 +486,17 @@ const getGlobalThis = () => {
486
486
  let activeEffectScope;
487
487
  class EffectScope {
488
488
  constructor(detached = false) {
489
+ /**
490
+ * @internal
491
+ */
489
492
  this.active = true;
493
+ /**
494
+ * @internal
495
+ */
490
496
  this.effects = [];
497
+ /**
498
+ * @internal
499
+ */
491
500
  this.cleanups = [];
492
501
  if (!detached && activeEffectScope) {
493
502
  this.parent = activeEffectScope;
@@ -497,18 +506,27 @@ class EffectScope {
497
506
  }
498
507
  run(fn) {
499
508
  if (this.active) {
509
+ const currentEffectScope = activeEffectScope;
500
510
  try {
501
511
  activeEffectScope = this;
502
512
  return fn();
503
513
  }
504
514
  finally {
505
- activeEffectScope = this.parent;
515
+ activeEffectScope = currentEffectScope;
506
516
  }
507
517
  }
508
518
  }
519
+ /**
520
+ * This should only be called on non-detached scopes
521
+ * @internal
522
+ */
509
523
  on() {
510
524
  activeEffectScope = this;
511
525
  }
526
+ /**
527
+ * This should only be called on non-detached scopes
528
+ * @internal
529
+ */
512
530
  off() {
513
531
  activeEffectScope = this.parent;
514
532
  }
@@ -646,10 +664,17 @@ class ReactiveEffect {
646
664
  activeEffect = this.parent;
647
665
  shouldTrack = lastShouldTrack;
648
666
  this.parent = undefined;
667
+ if (this.deferStop) {
668
+ this.stop();
669
+ }
649
670
  }
650
671
  }
651
672
  stop() {
652
- if (this.active) {
673
+ // stopped while running itself - defer the cleanup
674
+ if (activeEffect === this) {
675
+ this.deferStop = true;
676
+ }
677
+ else if (this.active) {
653
678
  cleanupEffect(this);
654
679
  if (this.onStop) {
655
680
  this.onStop();
@@ -814,7 +839,9 @@ function triggerEffects(dep, debuggerEventExtraInfo) {
814
839
  }
815
840
 
816
841
  const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
817
- const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
842
+ const builtInSymbols = new Set(
843
+ /*#__PURE__*/
844
+ Object.getOwnPropertyNames(Symbol)
818
845
  .map(key => Symbol[key])
819
846
  .filter(isSymbol));
820
847
  const get = /*#__PURE__*/ createGetter();
@@ -1696,7 +1723,7 @@ let preFlushIndex = 0;
1696
1723
  const pendingPostFlushCbs = [];
1697
1724
  let activePostFlushCbs = null;
1698
1725
  let postFlushIndex = 0;
1699
- const resolvedPromise = Promise.resolve();
1726
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
1700
1727
  let currentFlushPromise = null;
1701
1728
  let currentPreFlushParentJob = null;
1702
1729
  function nextTick(fn) {
@@ -2066,6 +2093,8 @@ function compatModelEmit(instance, event, args) {
2066
2093
  }
2067
2094
 
2068
2095
  function emit$1(instance, event, ...rawArgs) {
2096
+ if (instance.isUnmounted)
2097
+ return;
2069
2098
  const props = instance.vnode.props || EMPTY_OBJ;
2070
2099
  let args = rawArgs;
2071
2100
  const isModelListener = event.startsWith('update:');
@@ -3202,12 +3231,20 @@ const BaseTransitionImpl = {
3202
3231
  if (!children || !children.length) {
3203
3232
  return;
3204
3233
  }
3234
+ let child = children[0];
3235
+ if (children.length > 1) {
3236
+ // locate first non-comment child
3237
+ for (const c of children) {
3238
+ if (c.type !== Comment) {
3239
+ child = c;
3240
+ break;
3241
+ }
3242
+ }
3243
+ }
3205
3244
  // there's no need to track reactivity for these props so use the raw
3206
3245
  // props for a bit better perf
3207
3246
  const rawProps = toRaw(props);
3208
3247
  const { mode } = rawProps;
3209
- // at this point children has a guaranteed length of 1.
3210
- const child = children[0];
3211
3248
  if (state.isLeaving) {
3212
3249
  return emptyPlaceholder(child);
3213
3250
  }
@@ -3433,20 +3470,24 @@ function setTransitionHooks(vnode, hooks) {
3433
3470
  vnode.transition = hooks;
3434
3471
  }
3435
3472
  }
3436
- function getTransitionRawChildren(children, keepComment = false) {
3473
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3437
3474
  let ret = [];
3438
3475
  let keyedFragmentCount = 0;
3439
3476
  for (let i = 0; i < children.length; i++) {
3440
- const child = children[i];
3477
+ let child = children[i];
3478
+ // #5360 inherit parent key in case of <template v-for>
3479
+ const key = parentKey == null
3480
+ ? child.key
3481
+ : String(parentKey) + String(child.key != null ? child.key : i);
3441
3482
  // handle fragment children case, e.g. v-for
3442
3483
  if (child.type === Fragment) {
3443
3484
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3444
3485
  keyedFragmentCount++;
3445
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3486
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3446
3487
  }
3447
3488
  // comment placeholders should be skipped, e.g. v-if
3448
3489
  else if (keepComment || child.type !== Comment) {
3449
- ret.push(child);
3490
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3450
3491
  }
3451
3492
  }
3452
3493
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4380,6 +4421,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4380
4421
  const propsToUpdate = instance.vnode.dynamicProps;
4381
4422
  for (let i = 0; i < propsToUpdate.length; i++) {
4382
4423
  let key = propsToUpdate[i];
4424
+ // skip if the prop key is a declared emit event listener
4425
+ if (isEmitListener(instance.emitsOptions, key)) {
4426
+ continue;
4427
+ }
4383
4428
  // PROPS flag guarantees rawProps to be non-null
4384
4429
  const value = rawProps[key];
4385
4430
  if (options) {
@@ -4798,7 +4843,8 @@ function withDirectives(vnode, directives) {
4798
4843
  if (internalInstance === null) {
4799
4844
  return vnode;
4800
4845
  }
4801
- const instance = internalInstance.proxy;
4846
+ const instance = getExposeProxy(internalInstance) ||
4847
+ internalInstance.proxy;
4802
4848
  const bindings = vnode.dirs || (vnode.dirs = []);
4803
4849
  for (let i = 0; i < directives.length; i++) {
4804
4850
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4892,7 +4938,7 @@ function createCompatVue(createApp, createSingletonApp) {
4892
4938
  return vm;
4893
4939
  }
4894
4940
  }
4895
- Vue.version = `2.6.14-compat:${"3.2.30"}`;
4941
+ Vue.version = `2.6.14-compat:${"3.2.33"}`;
4896
4942
  Vue.config = singletonApp.config;
4897
4943
  Vue.use = (p, ...options) => {
4898
4944
  if (p && isFunction(p.install)) {
@@ -5279,6 +5325,9 @@ function createAppContext() {
5279
5325
  let uid = 0;
5280
5326
  function createAppAPI(render, hydrate) {
5281
5327
  return function createApp(rootComponent, rootProps = null) {
5328
+ if (!isFunction(rootComponent)) {
5329
+ rootComponent = Object.assign({}, rootComponent);
5330
+ }
5282
5331
  if (rootProps != null && !isObject(rootProps)) {
5283
5332
  rootProps = null;
5284
5333
  }
@@ -5421,6 +5470,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5421
5470
  if (!isArray(existing)) {
5422
5471
  if (_isString) {
5423
5472
  refs[ref] = [refValue];
5473
+ if (hasOwn(setupState, ref)) {
5474
+ setupState[ref] = refs[ref];
5475
+ }
5424
5476
  }
5425
5477
  else {
5426
5478
  ref.value = [refValue];
@@ -5607,6 +5659,7 @@ function createHydrationFunctions(rendererInternals) {
5607
5659
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5608
5660
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5609
5661
  // skip props & children if this is hoisted static nodes
5662
+ // #5405 in dev, always hydrate children for HMR
5610
5663
  if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5611
5664
  if (dirs) {
5612
5665
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
@@ -6747,7 +6800,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6747
6800
  const remove = vnode => {
6748
6801
  const { type, el, anchor, transition } = vnode;
6749
6802
  if (type === Fragment) {
6750
- removeFragment(el, anchor);
6803
+ {
6804
+ removeFragment(el, anchor);
6805
+ }
6751
6806
  return;
6752
6807
  }
6753
6808
  if (type === Static) {
@@ -8050,7 +8105,10 @@ function renderSlot(slots, name, props = {},
8050
8105
  // this is not a user-facing function, so the fallback is always generated by
8051
8106
  // the compiler and guaranteed to be a function returning an array
8052
8107
  fallback, noSlotted) {
8053
- if (currentRenderingInstance.isCE) {
8108
+ if (currentRenderingInstance.isCE ||
8109
+ (currentRenderingInstance.parent &&
8110
+ isAsyncWrapper(currentRenderingInstance.parent) &&
8111
+ currentRenderingInstance.parent.isCE)) {
8054
8112
  return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
8055
8113
  }
8056
8114
  let slot = slots[name];
@@ -8330,7 +8388,10 @@ const getPublicInstance = (i) => {
8330
8388
  return getExposeProxy(i) || i.proxy;
8331
8389
  return getPublicInstance(i.parent);
8332
8390
  };
8333
- const publicPropertiesMap = extend(Object.create(null), {
8391
+ const publicPropertiesMap =
8392
+ // Move PURE marker to new line to workaround compiler discarding it
8393
+ // due to type annotation
8394
+ /*#__PURE__*/ extend(Object.create(null), {
8334
8395
  $: i => i,
8335
8396
  $el: i => i.vnode.el,
8336
8397
  $data: i => i.data,
@@ -8429,7 +8490,9 @@ const PublicInstanceProxyHandlers = {
8429
8490
  }
8430
8491
  else {
8431
8492
  const val = globalProperties[key];
8432
- return isFunction(val) ? val.bind(instance.proxy) : val;
8493
+ return isFunction(val)
8494
+ ? Object.assign(val.bind(instance.proxy), val)
8495
+ : val;
8433
8496
  }
8434
8497
  }
8435
8498
  }
@@ -8439,9 +8502,11 @@ const PublicInstanceProxyHandlers = {
8439
8502
  const { data, setupState, ctx } = instance;
8440
8503
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8441
8504
  setupState[key] = value;
8505
+ return true;
8442
8506
  }
8443
8507
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8444
8508
  data[key] = value;
8509
+ return true;
8445
8510
  }
8446
8511
  else if (hasOwn(instance.props, key)) {
8447
8512
  return false;
@@ -8465,6 +8530,16 @@ const PublicInstanceProxyHandlers = {
8465
8530
  hasOwn(ctx, key) ||
8466
8531
  hasOwn(publicPropertiesMap, key) ||
8467
8532
  hasOwn(appContext.config.globalProperties, key));
8533
+ },
8534
+ defineProperty(target, key, descriptor) {
8535
+ if (descriptor.get != null) {
8536
+ // invalidate key cache of a getter based property #5417
8537
+ target._.accessCache[key] = 0;
8538
+ }
8539
+ else if (hasOwn(descriptor, 'value')) {
8540
+ this.set(target, key, descriptor.value, null);
8541
+ }
8542
+ return Reflect.defineProperty(target, key, descriptor);
8468
8543
  }
8469
8544
  };
8470
8545
  const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
@@ -8997,7 +9072,7 @@ function isMemoSame(cached, memo) {
8997
9072
  }
8998
9073
 
8999
9074
  // Core API ------------------------------------------------------------------
9000
- const version = "3.2.30";
9075
+ const version = "3.2.33";
9001
9076
  const _ssrUtils = {
9002
9077
  createComponentInstance,
9003
9078
  setupComponent,
@@ -9029,7 +9104,7 @@ const compatUtils = (_compatUtils );
9029
9104
 
9030
9105
  const svgNS = 'http://www.w3.org/2000/svg';
9031
9106
  const doc = (typeof document !== 'undefined' ? document : null);
9032
- const templateContainer = doc && doc.createElement('template');
9107
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
9033
9108
  const nodeOps = {
9034
9109
  insert: (child, parent, anchor) => {
9035
9110
  parent.insertBefore(child, anchor || null);
@@ -9180,6 +9255,8 @@ function setStyle(style, name, val) {
9180
9255
  val.forEach(v => setStyle(style, name, v));
9181
9256
  }
9182
9257
  else {
9258
+ if (val == null)
9259
+ val = '';
9183
9260
  if (name.startsWith('--')) {
9184
9261
  // custom property definition
9185
9262
  style.setProperty(name, val);
@@ -9301,70 +9378,72 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9301
9378
  }
9302
9379
  return;
9303
9380
  }
9381
+ let needRemove = false;
9304
9382
  if (value === '' || value == null) {
9305
9383
  const type = typeof el[key];
9306
9384
  if (type === 'boolean') {
9307
9385
  // e.g. <select multiple> compiles to { multiple: '' }
9308
- el[key] = includeBooleanAttr(value);
9309
- return;
9386
+ value = includeBooleanAttr(value);
9310
9387
  }
9311
9388
  else if (value == null && type === 'string') {
9312
9389
  // e.g. <div :id="null">
9313
- el[key] = '';
9314
- el.removeAttribute(key);
9315
- return;
9390
+ value = '';
9391
+ needRemove = true;
9316
9392
  }
9317
9393
  else if (type === 'number') {
9318
9394
  // e.g. <img :width="null">
9319
9395
  // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9320
- try {
9321
- el[key] = 0;
9322
- }
9323
- catch (_a) { }
9324
- el.removeAttribute(key);
9325
- return;
9396
+ value = 0;
9397
+ needRemove = true;
9326
9398
  }
9327
9399
  }
9328
- if (value === false &&
9329
- compatUtils.isCompatEnabled("ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */, parentComponent)) {
9330
- const type = typeof el[key];
9331
- if (type === 'string' || type === 'number') {
9332
- el[key] = type === 'number' ? 0 : '';
9333
- el.removeAttribute(key);
9334
- return;
9400
+ else {
9401
+ if (value === false &&
9402
+ compatUtils.isCompatEnabled("ATTR_FALSE_VALUE" /* ATTR_FALSE_VALUE */, parentComponent)) {
9403
+ const type = typeof el[key];
9404
+ if (type === 'string' || type === 'number') {
9405
+ value = type === 'number' ? 0 : '';
9406
+ needRemove = true;
9407
+ }
9335
9408
  }
9336
9409
  }
9337
- // some properties perform value validation and throw
9410
+ // some properties perform value validation and throw,
9411
+ // some properties has getter, no setter, will error in 'use strict'
9412
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
9338
9413
  try {
9339
9414
  el[key] = value;
9340
9415
  }
9341
9416
  catch (e) {
9342
9417
  }
9418
+ needRemove && el.removeAttribute(key);
9343
9419
  }
9344
9420
 
9345
9421
  // Async edge case fix requires storing an event listener's attach timestamp.
9346
- let _getNow = Date.now;
9347
- let skipTimestampCheck = false;
9348
- if (typeof window !== 'undefined') {
9349
- // Determine what event timestamp the browser is using. Annoyingly, the
9350
- // timestamp can either be hi-res (relative to page load) or low-res
9351
- // (relative to UNIX epoch), so in order to compare time we have to use the
9352
- // same timestamp type when saving the flush timestamp.
9353
- if (_getNow() > document.createEvent('Event').timeStamp) {
9354
- // if the low-res timestamp which is bigger than the event timestamp
9355
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9356
- // and we need to use the hi-res version for event listeners as well.
9357
- _getNow = () => performance.now();
9358
- }
9359
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9360
- // and does not fire microtasks in between event propagation, so safe to exclude.
9361
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9362
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9363
- }
9422
+ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
9423
+ let _getNow = Date.now;
9424
+ let skipTimestampCheck = false;
9425
+ if (typeof window !== 'undefined') {
9426
+ // Determine what event timestamp the browser is using. Annoyingly, the
9427
+ // timestamp can either be hi-res (relative to page load) or low-res
9428
+ // (relative to UNIX epoch), so in order to compare time we have to use the
9429
+ // same timestamp type when saving the flush timestamp.
9430
+ if (Date.now() > document.createEvent('Event').timeStamp) {
9431
+ // if the low-res timestamp which is bigger than the event timestamp
9432
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9433
+ // and we need to use the hi-res version for event listeners as well.
9434
+ _getNow = () => performance.now();
9435
+ }
9436
+ // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9437
+ // and does not fire microtasks in between event propagation, so safe to exclude.
9438
+ const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9439
+ skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9440
+ }
9441
+ return [_getNow, skipTimestampCheck];
9442
+ })();
9364
9443
  // To avoid the overhead of repeatedly calling performance.now(), we cache
9365
9444
  // and use the same timestamp for all event listeners attached in the same tick.
9366
9445
  let cachedNow = 0;
9367
- const p = Promise.resolve();
9446
+ const p = /*#__PURE__*/ Promise.resolve();
9368
9447
  const reset = () => {
9369
9448
  cachedNow = 0;
9370
9449
  };
@@ -9489,13 +9568,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
9489
9568
  }
9490
9569
  return false;
9491
9570
  }
9492
- // spellcheck and draggable are numerated attrs, however their
9493
- // corresponding DOM properties are actually booleans - this leads to
9494
- // setting it with a string "false" value leading it to be coerced to
9495
- // `true`, so we need to always treat them as attributes.
9571
+ // these are enumerated attrs, however their corresponding DOM properties
9572
+ // are actually booleans - this leads to setting it with a string "false"
9573
+ // value leading it to be coerced to `true`, so we need to always treat
9574
+ // them as attributes.
9496
9575
  // Note that `contentEditable` doesn't have this problem: its DOM
9497
9576
  // property is also enumerated string values.
9498
- if (key === 'spellcheck' || key === 'draggable') {
9577
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
9499
9578
  return false;
9500
9579
  }
9501
9580
  // #1787, #2840 form property on form elements is readonly and must be set as
@@ -10573,7 +10652,7 @@ function initVShowForSSR() {
10573
10652
  };
10574
10653
  }
10575
10654
 
10576
- const rendererOptions = extend({ patchProp }, nodeOps);
10655
+ const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
10577
10656
  // lazy create the renderer - this makes core renderer logic tree-shakable
10578
10657
  // in case the user only imports reactivity utilities from Vue.
10579
10658
  let renderer;