@vue/runtime-dom 3.2.2 → 3.2.6

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.
@@ -34,7 +34,14 @@ var VueRuntimeDOM = (function (exports) {
34
34
  * - readonly -> readOnly
35
35
  */
36
36
  const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
37
- const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
37
+ const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
38
+ /**
39
+ * Boolean attributes should be included if the value is truthy or ''.
40
+ * e.g. <select multiple> compiles to { multiple: '' }
41
+ */
42
+ function includeBooleanAttr(value) {
43
+ return !!value || value === '';
44
+ }
38
45
 
39
46
  function normalizeStyle(value) {
40
47
  if (isArray(value)) {
@@ -188,7 +195,9 @@ var VueRuntimeDOM = (function (exports) {
188
195
  const toDisplayString = (val) => {
189
196
  return val == null
190
197
  ? ''
191
- : isArray(val) || (isObject(val) && val.toString === objectToString)
198
+ : isArray(val) ||
199
+ (isObject(val) &&
200
+ (val.toString === objectToString || !isFunction(val.toString)))
192
201
  ? JSON.stringify(val, replacer, 2)
193
202
  : String(val);
194
203
  };
@@ -404,7 +413,7 @@ var VueRuntimeDOM = (function (exports) {
404
413
  activeEffectScope.cleanups.push(fn);
405
414
  }
406
415
  else {
407
- warn(`onDispose() is called when there is no active effect scope` +
416
+ warn(`onScopeDispose() is called when there is no active effect scope` +
408
417
  ` to be associated with.`);
409
418
  }
410
419
  }
@@ -1271,13 +1280,13 @@ var VueRuntimeDOM = (function (exports) {
1271
1280
  return Boolean(r && r.__v_isRef === true);
1272
1281
  }
1273
1282
  function ref(value) {
1274
- return createRef(value);
1283
+ return createRef(value, false);
1275
1284
  }
1276
1285
  function shallowRef(value) {
1277
1286
  return createRef(value, true);
1278
1287
  }
1279
1288
  class RefImpl {
1280
- constructor(value, _shallow = false) {
1289
+ constructor(value, _shallow) {
1281
1290
  this._shallow = _shallow;
1282
1291
  this.dep = undefined;
1283
1292
  this.__v_isRef = true;
@@ -1297,7 +1306,7 @@ var VueRuntimeDOM = (function (exports) {
1297
1306
  }
1298
1307
  }
1299
1308
  }
1300
- function createRef(rawValue, shallow = false) {
1309
+ function createRef(rawValue, shallow) {
1301
1310
  if (isRef(rawValue)) {
1302
1311
  return rawValue;
1303
1312
  }
@@ -1369,9 +1378,8 @@ var VueRuntimeDOM = (function (exports) {
1369
1378
  }
1370
1379
  }
1371
1380
  function toRef(object, key) {
1372
- return isRef(object[key])
1373
- ? object[key]
1374
- : new ObjectRefImpl(object, key);
1381
+ const val = object[key];
1382
+ return isRef(val) ? val : new ObjectRefImpl(object, key);
1375
1383
  }
1376
1384
 
1377
1385
  class ComputedRefImpl {
@@ -2216,8 +2224,7 @@ var VueRuntimeDOM = (function (exports) {
2216
2224
  const keys = Object.keys(fallthroughAttrs);
2217
2225
  const { shapeFlag } = root;
2218
2226
  if (keys.length) {
2219
- if (shapeFlag & 1 /* ELEMENT */ ||
2220
- shapeFlag & 6 /* COMPONENT */) {
2227
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2221
2228
  if (propsOptions && keys.some(isModelListener)) {
2222
2229
  // If a v-model listener (onUpdate:xxx) has a corresponding declared
2223
2230
  // prop, it indicates this component expects to handle v-model and
@@ -2265,8 +2272,7 @@ var VueRuntimeDOM = (function (exports) {
2265
2272
  if (false &&
2266
2273
  isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2267
2274
  vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2268
- (root.shapeFlag & 1 /* ELEMENT */ ||
2269
- root.shapeFlag & 6 /* COMPONENT */)) ;
2275
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) ;
2270
2276
  // inherit directives
2271
2277
  if (vnode.dirs) {
2272
2278
  if (true && !isElementRoot(root)) {
@@ -2367,8 +2373,7 @@ var VueRuntimeDOM = (function (exports) {
2367
2373
  return res;
2368
2374
  };
2369
2375
  const isElementRoot = (vnode) => {
2370
- return (vnode.shapeFlag & 6 /* COMPONENT */ ||
2371
- vnode.shapeFlag & 1 /* ELEMENT */ ||
2376
+ return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
2372
2377
  vnode.type === Comment$1 // potential v-if branch switch
2373
2378
  );
2374
2379
  };
@@ -4576,13 +4581,13 @@ var VueRuntimeDOM = (function (exports) {
4576
4581
  ? value.map(normalizeVNode)
4577
4582
  : [normalizeVNode(value)];
4578
4583
  const normalizeSlot = (key, rawSlot, ctx) => {
4579
- const normalized = withCtx((props) => {
4584
+ const normalized = withCtx((...args) => {
4580
4585
  if (currentInstance) {
4581
4586
  warn$1(`Slot "${key}" invoked outside of the render function: ` +
4582
4587
  `this will not track dependencies used in the slot. ` +
4583
4588
  `Invoke the slot function inside the render function instead.`);
4584
4589
  }
4585
- return normalizeSlotValue(rawSlot(props));
4590
+ return normalizeSlotValue(rawSlot(...args));
4586
4591
  }, ctx);
4587
4592
  normalized._c = false;
4588
4593
  return normalized;
@@ -5094,8 +5099,7 @@ var VueRuntimeDOM = (function (exports) {
5094
5099
  if (props) {
5095
5100
  if (forcePatchValue ||
5096
5101
  !optimized ||
5097
- patchFlag & 16 /* FULL_PROPS */ ||
5098
- patchFlag & 32 /* HYDRATE_EVENTS */) {
5102
+ patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
5099
5103
  for (const key in props) {
5100
5104
  if ((forcePatchValue && key.endsWith('value')) ||
5101
5105
  (isOn(key) && !isReservedProp(key))) {
@@ -5574,6 +5578,17 @@ var VueRuntimeDOM = (function (exports) {
5574
5578
  optimized = false;
5575
5579
  dynamicChildren = null;
5576
5580
  }
5581
+ const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
5582
+ if (dynamicChildren) {
5583
+ patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
5584
+ if (parentComponent && parentComponent.type.__hmrId) {
5585
+ traverseStaticChildren(n1, n2);
5586
+ }
5587
+ }
5588
+ else if (!optimized) {
5589
+ // full diff
5590
+ patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
5591
+ }
5577
5592
  if (patchFlag > 0) {
5578
5593
  // the presence of a patchFlag means this element's render code was
5579
5594
  // generated by the compiler and can take the fast path.
@@ -5628,17 +5643,6 @@ var VueRuntimeDOM = (function (exports) {
5628
5643
  // unoptimized, full diff
5629
5644
  patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
5630
5645
  }
5631
- const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
5632
- if (dynamicChildren) {
5633
- patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
5634
- if (parentComponent && parentComponent.type.__hmrId) {
5635
- traverseStaticChildren(n1, n2);
5636
- }
5637
- }
5638
- else if (!optimized) {
5639
- // full diff
5640
- patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
5641
- }
5642
5646
  if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
5643
5647
  queuePostRenderEffect(() => {
5644
5648
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
@@ -5663,8 +5667,7 @@ var VueRuntimeDOM = (function (exports) {
5663
5667
  // which also requires the correct parent container
5664
5668
  !isSameVNodeType(oldVNode, newVNode) ||
5665
5669
  // - In the case of a component, it could contain anything.
5666
- oldVNode.shapeFlag & 6 /* COMPONENT */ ||
5667
- oldVNode.shapeFlag & 64 /* TELEPORT */)
5670
+ oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
5668
5671
  ? hostParentNode(oldVNode.el)
5669
5672
  : // In other cases, the parent container is not actually used so we
5670
5673
  // just pass the block element here to avoid a DOM parentNode call.
@@ -5847,13 +5850,15 @@ var VueRuntimeDOM = (function (exports) {
5847
5850
  let vnodeHook;
5848
5851
  const { el, props } = initialVNode;
5849
5852
  const { bm, m, parent } = instance;
5853
+ const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5850
5854
  effect.allowRecurse = false;
5851
5855
  // beforeMount hook
5852
5856
  if (bm) {
5853
5857
  invokeArrayFns(bm);
5854
5858
  }
5855
5859
  // onVnodeBeforeMount
5856
- if ((vnodeHook = props && props.onVnodeBeforeMount)) {
5860
+ if (!isAsyncWrapperVNode &&
5861
+ (vnodeHook = props && props.onVnodeBeforeMount)) {
5857
5862
  invokeVNodeHook(vnodeHook, parent, initialVNode);
5858
5863
  }
5859
5864
  effect.allowRecurse = true;
@@ -5875,7 +5880,7 @@ var VueRuntimeDOM = (function (exports) {
5875
5880
  endMeasure(instance, `hydrate`);
5876
5881
  }
5877
5882
  };
5878
- if (isAsyncWrapper(initialVNode)) {
5883
+ if (isAsyncWrapperVNode) {
5879
5884
  initialVNode.type.__asyncLoader().then(
5880
5885
  // note: we are moving the render call into an async callback,
5881
5886
  // which means it won't track dependencies - but it's ok because
@@ -5909,7 +5914,8 @@ var VueRuntimeDOM = (function (exports) {
5909
5914
  queuePostRenderEffect(m, parentSuspense);
5910
5915
  }
5911
5916
  // onVnodeMounted
5912
- if ((vnodeHook = props && props.onVnodeMounted)) {
5917
+ if (!isAsyncWrapperVNode &&
5918
+ (vnodeHook = props && props.onVnodeMounted)) {
5913
5919
  const scopedInitialVNode = initialVNode;
5914
5920
  queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
5915
5921
  }
@@ -5936,6 +5942,8 @@ var VueRuntimeDOM = (function (exports) {
5936
5942
  {
5937
5943
  pushWarningContext(next || instance.vnode);
5938
5944
  }
5945
+ // Disallow component effect recursion during pre-lifecycle hooks.
5946
+ effect.allowRecurse = false;
5939
5947
  if (next) {
5940
5948
  next.el = vnode.el;
5941
5949
  updateComponentPreRender(instance, next, optimized);
@@ -5943,8 +5951,6 @@ var VueRuntimeDOM = (function (exports) {
5943
5951
  else {
5944
5952
  next = vnode;
5945
5953
  }
5946
- // Disallow component effect recursion during pre-lifecycle hooks.
5947
- effect.allowRecurse = false;
5948
5954
  // beforeUpdate hook
5949
5955
  if (bu) {
5950
5956
  invokeArrayFns(bu);
@@ -6347,8 +6353,10 @@ var VueRuntimeDOM = (function (exports) {
6347
6353
  return;
6348
6354
  }
6349
6355
  const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
6356
+ const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
6350
6357
  let vnodeHook;
6351
- if ((vnodeHook = props && props.onVnodeBeforeUnmount)) {
6358
+ if (shouldInvokeVnodeHook &&
6359
+ (vnodeHook = props && props.onVnodeBeforeUnmount)) {
6352
6360
  invokeVNodeHook(vnodeHook, parentComponent, vnode);
6353
6361
  }
6354
6362
  if (shapeFlag & 6 /* COMPONENT */) {
@@ -6373,8 +6381,8 @@ var VueRuntimeDOM = (function (exports) {
6373
6381
  unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
6374
6382
  }
6375
6383
  else if ((type === Fragment &&
6376
- (patchFlag & 128 /* KEYED_FRAGMENT */ ||
6377
- patchFlag & 256 /* UNKEYED_FRAGMENT */)) ||
6384
+ patchFlag &
6385
+ (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
6378
6386
  (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
6379
6387
  unmountChildren(children, parentComponent, parentSuspense);
6380
6388
  }
@@ -6382,7 +6390,9 @@ var VueRuntimeDOM = (function (exports) {
6382
6390
  remove(vnode);
6383
6391
  }
6384
6392
  }
6385
- if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
6393
+ if ((shouldInvokeVnodeHook &&
6394
+ (vnodeHook = props && props.onVnodeUnmounted)) ||
6395
+ shouldInvokeDirs) {
6386
6396
  queuePostRenderEffect(() => {
6387
6397
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
6388
6398
  shouldInvokeDirs &&
@@ -7326,7 +7336,7 @@ var VueRuntimeDOM = (function (exports) {
7326
7336
  type = 16 /* ARRAY_CHILDREN */;
7327
7337
  }
7328
7338
  else if (typeof children === 'object') {
7329
- if (shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) {
7339
+ if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7330
7340
  // Normalize slot to plain children for plain element and Teleport
7331
7341
  const slot = children.default;
7332
7342
  if (slot) {
@@ -9214,20 +9224,8 @@ var VueRuntimeDOM = (function (exports) {
9214
9224
  return true;
9215
9225
  }
9216
9226
 
9217
- function $ref() { }
9218
- function $shallowRef(arg) {
9219
- return arg;
9220
- }
9221
- function $computed() { }
9222
- function $fromRefs() {
9223
- return null;
9224
- }
9225
- function $raw() {
9226
- return null;
9227
- }
9228
-
9229
9227
  // Core API ------------------------------------------------------------------
9230
- const version = "3.2.2";
9228
+ const version = "3.2.6";
9231
9229
  /**
9232
9230
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9233
9231
  * @internal
@@ -9434,7 +9432,7 @@ var VueRuntimeDOM = (function (exports) {
9434
9432
  // note we are only checking boolean attributes that don't have a
9435
9433
  // corresponding dom prop of the same name here.
9436
9434
  const isBoolean = isSpecialBooleanAttr(key);
9437
- if (value == null || (isBoolean && value === false)) {
9435
+ if (value == null || (isBoolean && !includeBooleanAttr(value))) {
9438
9436
  el.removeAttribute(key);
9439
9437
  }
9440
9438
  else {
@@ -9472,9 +9470,9 @@ var VueRuntimeDOM = (function (exports) {
9472
9470
  }
9473
9471
  if (value === '' || value == null) {
9474
9472
  const type = typeof el[key];
9475
- if (value === '' && type === 'boolean') {
9473
+ if (type === 'boolean') {
9476
9474
  // e.g. <select multiple> compiles to { multiple: '' }
9477
- el[key] = true;
9475
+ el[key] = includeBooleanAttr(value);
9478
9476
  return;
9479
9477
  }
9480
9478
  else if (value == null && type === 'string') {
@@ -10816,11 +10814,6 @@ var VueRuntimeDOM = (function (exports) {
10816
10814
  return container;
10817
10815
  }
10818
10816
 
10819
- exports.$computed = $computed;
10820
- exports.$fromRefs = $fromRefs;
10821
- exports.$raw = $raw;
10822
- exports.$ref = $ref;
10823
- exports.$shallowRef = $shallowRef;
10824
10817
  exports.BaseTransition = BaseTransition;
10825
10818
  exports.Comment = Comment$1;
10826
10819
  exports.EffectScope = EffectScope;