@vue/runtime-dom 3.2.29 → 3.2.30

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.
@@ -198,13 +198,15 @@ function looseIndexOf(arr, val) {
198
198
  * @private
199
199
  */
200
200
  const toDisplayString = (val) => {
201
- return val == null
202
- ? ''
203
- : isArray(val) ||
204
- (isObject(val) &&
205
- (val.toString === objectToString || !isFunction(val.toString)))
206
- ? JSON.stringify(val, replacer, 2)
207
- : String(val);
201
+ return isString(val)
202
+ ? val
203
+ : val == null
204
+ ? ''
205
+ : isArray(val) ||
206
+ (isObject(val) &&
207
+ (val.toString === objectToString || !isFunction(val.toString)))
208
+ ? JSON.stringify(val, replacer, 2)
209
+ : String(val);
208
210
  };
209
211
  const replacer = (_key, val) => {
210
212
  // can't use isRef here since @vue/shared has no deps
@@ -278,6 +280,7 @@ const isReservedProp = /*#__PURE__*/ makeMap(
278
280
  'onVnodeBeforeMount,onVnodeMounted,' +
279
281
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
280
282
  'onVnodeBeforeUnmount,onVnodeUnmounted');
283
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
281
284
  const cacheStringFunction = (fn) => {
282
285
  const cache = Object.create(null);
283
286
  return ((str) => {
@@ -343,7 +346,6 @@ function warn(msg, ...args) {
343
346
  }
344
347
 
345
348
  let activeEffectScope;
346
- const effectScopeStack = [];
347
349
  class EffectScope {
348
350
  constructor(detached = false) {
349
351
  this.active = true;
@@ -358,11 +360,11 @@ class EffectScope {
358
360
  run(fn) {
359
361
  if (this.active) {
360
362
  try {
361
- this.on();
363
+ activeEffectScope = this;
362
364
  return fn();
363
365
  }
364
366
  finally {
365
- this.off();
367
+ activeEffectScope = this.parent;
366
368
  }
367
369
  }
368
370
  else {
@@ -370,23 +372,24 @@ class EffectScope {
370
372
  }
371
373
  }
372
374
  on() {
373
- if (this.active) {
374
- effectScopeStack.push(this);
375
- activeEffectScope = this;
376
- }
375
+ activeEffectScope = this;
377
376
  }
378
377
  off() {
379
- if (this.active) {
380
- effectScopeStack.pop();
381
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
382
- }
378
+ activeEffectScope = this.parent;
383
379
  }
384
380
  stop(fromParent) {
385
381
  if (this.active) {
386
- this.effects.forEach(e => e.stop());
387
- this.cleanups.forEach(cleanup => cleanup());
382
+ let i, l;
383
+ for (i = 0, l = this.effects.length; i < l; i++) {
384
+ this.effects[i].stop();
385
+ }
386
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
387
+ this.cleanups[i]();
388
+ }
388
389
  if (this.scopes) {
389
- this.scopes.forEach(e => e.stop(true));
390
+ for (i = 0, l = this.scopes.length; i < l; i++) {
391
+ this.scopes[i].stop(true);
392
+ }
390
393
  }
391
394
  // nested scope, dereference from parent to avoid memory leaks
392
395
  if (this.parent && !fromParent) {
@@ -404,8 +407,7 @@ class EffectScope {
404
407
  function effectScope(detached) {
405
408
  return new EffectScope(detached);
406
409
  }
407
- function recordEffectScope(effect, scope) {
408
- scope = scope || activeEffectScope;
410
+ function recordEffectScope(effect, scope = activeEffectScope) {
409
411
  if (scope && scope.active) {
410
412
  scope.effects.push(effect);
411
413
  }
@@ -468,7 +470,6 @@ let trackOpBit = 1;
468
470
  * When recursion depth is greater, fall back to using a full cleanup.
469
471
  */
470
472
  const maxMarkerBits = 30;
471
- const effectStack = [];
472
473
  let activeEffect;
473
474
  const ITERATE_KEY = Symbol('iterate' );
474
475
  const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
@@ -478,35 +479,42 @@ class ReactiveEffect {
478
479
  this.scheduler = scheduler;
479
480
  this.active = true;
480
481
  this.deps = [];
482
+ this.parent = undefined;
481
483
  recordEffectScope(this, scope);
482
484
  }
483
485
  run() {
484
486
  if (!this.active) {
485
487
  return this.fn();
486
488
  }
487
- if (!effectStack.length || !effectStack.includes(this)) {
488
- try {
489
- effectStack.push((activeEffect = this));
490
- enableTracking();
491
- trackOpBit = 1 << ++effectTrackDepth;
492
- if (effectTrackDepth <= maxMarkerBits) {
493
- initDepMarkers(this);
494
- }
495
- else {
496
- cleanupEffect(this);
497
- }
498
- return this.fn();
489
+ let parent = activeEffect;
490
+ let lastShouldTrack = shouldTrack;
491
+ while (parent) {
492
+ if (parent === this) {
493
+ return;
499
494
  }
500
- finally {
501
- if (effectTrackDepth <= maxMarkerBits) {
502
- finalizeDepMarkers(this);
503
- }
504
- trackOpBit = 1 << --effectTrackDepth;
505
- resetTracking();
506
- effectStack.pop();
507
- const n = effectStack.length;
508
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
495
+ parent = parent.parent;
496
+ }
497
+ try {
498
+ this.parent = activeEffect;
499
+ activeEffect = this;
500
+ shouldTrack = true;
501
+ trackOpBit = 1 << ++effectTrackDepth;
502
+ if (effectTrackDepth <= maxMarkerBits) {
503
+ initDepMarkers(this);
509
504
  }
505
+ else {
506
+ cleanupEffect(this);
507
+ }
508
+ return this.fn();
509
+ }
510
+ finally {
511
+ if (effectTrackDepth <= maxMarkerBits) {
512
+ finalizeDepMarkers(this);
513
+ }
514
+ trackOpBit = 1 << --effectTrackDepth;
515
+ activeEffect = this.parent;
516
+ shouldTrack = lastShouldTrack;
517
+ this.parent = undefined;
510
518
  }
511
519
  }
512
520
  stop() {
@@ -554,32 +562,24 @@ function pauseTracking() {
554
562
  trackStack.push(shouldTrack);
555
563
  shouldTrack = false;
556
564
  }
557
- function enableTracking() {
558
- trackStack.push(shouldTrack);
559
- shouldTrack = true;
560
- }
561
565
  function resetTracking() {
562
566
  const last = trackStack.pop();
563
567
  shouldTrack = last === undefined ? true : last;
564
568
  }
565
569
  function track(target, type, key) {
566
- if (!isTracking()) {
567
- return;
568
- }
569
- let depsMap = targetMap.get(target);
570
- if (!depsMap) {
571
- targetMap.set(target, (depsMap = new Map()));
572
- }
573
- let dep = depsMap.get(key);
574
- if (!dep) {
575
- depsMap.set(key, (dep = createDep()));
570
+ if (shouldTrack && activeEffect) {
571
+ let depsMap = targetMap.get(target);
572
+ if (!depsMap) {
573
+ targetMap.set(target, (depsMap = new Map()));
574
+ }
575
+ let dep = depsMap.get(key);
576
+ if (!dep) {
577
+ depsMap.set(key, (dep = createDep()));
578
+ }
579
+ const eventInfo = { effect: activeEffect, target, type, key }
580
+ ;
581
+ trackEffects(dep, eventInfo);
576
582
  }
577
- const eventInfo = { effect: activeEffect, target, type, key }
578
- ;
579
- trackEffects(dep, eventInfo);
580
- }
581
- function isTracking() {
582
- return shouldTrack && activeEffect !== undefined;
583
583
  }
584
584
  function trackEffects(dep, debuggerEventExtraInfo) {
585
585
  let shouldTrack = false;
@@ -1264,13 +1264,10 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1264
1264
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1265
1265
 
1266
1266
  function trackRefValue(ref) {
1267
- if (isTracking()) {
1267
+ if (shouldTrack && activeEffect) {
1268
1268
  ref = toRaw(ref);
1269
- if (!ref.dep) {
1270
- ref.dep = createDep();
1271
- }
1272
1269
  {
1273
- trackEffects(ref.dep, {
1270
+ trackEffects(ref.dep || (ref.dep = createDep()), {
1274
1271
  target: ref,
1275
1272
  type: "get" /* GET */,
1276
1273
  key: 'value'
@@ -1292,7 +1289,7 @@ function triggerRefValue(ref, newVal) {
1292
1289
  }
1293
1290
  }
1294
1291
  function isRef(r) {
1295
- return Boolean(r && r.__v_isRef === true);
1292
+ return !!(r && r.__v_isRef === true);
1296
1293
  }
1297
1294
  function ref(value) {
1298
1295
  return createRef(value, false);
@@ -5105,7 +5102,6 @@ return withDirectives(h(comp), [
5105
5102
  [bar, this.y]
5106
5103
  ])
5107
5104
  */
5108
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5109
5105
  function validateDirectiveName(name) {
5110
5106
  if (isBuiltInDirective(name)) {
5111
5107
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -9031,7 +9027,7 @@ function isMemoSame(cached, memo) {
9031
9027
  }
9032
9028
 
9033
9029
  // Core API ------------------------------------------------------------------
9034
- const version = "3.2.29";
9030
+ const version = "3.2.30";
9035
9031
  /**
9036
9032
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9037
9033
  * @internal