@vue/runtime-dom 3.4.0-alpha.1 → 3.4.0-alpha.2

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.
@@ -2,12 +2,8 @@ var VueRuntimeDOM = (function (exports) {
2
2
  'use strict';
3
3
 
4
4
  function makeMap(str, expectsLowerCase) {
5
- const map = /* @__PURE__ */ Object.create(null);
6
- const list = str.split(",");
7
- for (let i = 0; i < list.length; i++) {
8
- map[list[i]] = true;
9
- }
10
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
5
+ const set = new Set(str.split(","));
6
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
11
7
  }
12
8
 
13
9
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -964,7 +960,7 @@ var VueRuntimeDOM = (function (exports) {
964
960
  toRaw(this)
965
961
  );
966
962
  }
967
- return type === "delete" ? false : this;
963
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
968
964
  };
969
965
  }
970
966
  function createInstrumentations() {
@@ -1220,9 +1216,10 @@ var VueRuntimeDOM = (function (exports) {
1220
1216
  this.dep = void 0;
1221
1217
  this.__v_isRef = true;
1222
1218
  this["__v_isReadonly"] = false;
1223
- this.effect = new ReactiveEffect(getter, () => {
1224
- triggerRefValue(this, 1);
1225
- });
1219
+ this.effect = new ReactiveEffect(
1220
+ () => getter(this._value),
1221
+ () => triggerRefValue(this, 1)
1222
+ );
1226
1223
  this.effect.computed = this;
1227
1224
  this.effect.active = this._cacheable = !isSSR;
1228
1225
  this["__v_isReadonly"] = isReadonly;
@@ -2249,9 +2246,19 @@ var VueRuntimeDOM = (function (exports) {
2249
2246
  try {
2250
2247
  if (vnode.shapeFlag & 4) {
2251
2248
  const proxyToUse = withProxy || proxy;
2249
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2250
+ get(target, key, receiver) {
2251
+ warn(
2252
+ `Property '${String(
2253
+ key
2254
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2255
+ );
2256
+ return Reflect.get(target, key, receiver);
2257
+ }
2258
+ }) : proxyToUse;
2252
2259
  result = normalizeVNode(
2253
2260
  render.call(
2254
- proxyToUse,
2261
+ thisProxy,
2255
2262
  proxyToUse,
2256
2263
  renderCache,
2257
2264
  props,
@@ -2486,6 +2493,61 @@ var VueRuntimeDOM = (function (exports) {
2486
2493
  }
2487
2494
  }
2488
2495
 
2496
+ const COMPONENTS = "components";
2497
+ const DIRECTIVES = "directives";
2498
+ function resolveComponent(name, maybeSelfReference) {
2499
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2500
+ }
2501
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2502
+ function resolveDynamicComponent(component) {
2503
+ if (isString(component)) {
2504
+ return resolveAsset(COMPONENTS, component, false) || component;
2505
+ } else {
2506
+ return component || NULL_DYNAMIC_COMPONENT;
2507
+ }
2508
+ }
2509
+ function resolveDirective(name) {
2510
+ return resolveAsset(DIRECTIVES, name);
2511
+ }
2512
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2513
+ const instance = currentRenderingInstance || currentInstance;
2514
+ if (instance) {
2515
+ const Component = instance.type;
2516
+ if (type === COMPONENTS) {
2517
+ const selfName = getComponentName(
2518
+ Component,
2519
+ false
2520
+ /* do not include inferred name to avoid breaking existing code */
2521
+ );
2522
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2523
+ return Component;
2524
+ }
2525
+ }
2526
+ const res = (
2527
+ // local registration
2528
+ // check instance[type] first which is resolved for options API
2529
+ resolve(instance[type] || Component[type], name) || // global registration
2530
+ resolve(instance.appContext[type], name)
2531
+ );
2532
+ if (!res && maybeSelfReference) {
2533
+ return Component;
2534
+ }
2535
+ if (warnMissing && !res) {
2536
+ const extra = type === COMPONENTS ? `
2537
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
2538
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
2539
+ }
2540
+ return res;
2541
+ } else {
2542
+ warn(
2543
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
2544
+ );
2545
+ }
2546
+ }
2547
+ function resolve(registry, name) {
2548
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2549
+ }
2550
+
2489
2551
  const isSuspense = (type) => type.__isSuspense;
2490
2552
  const SuspenseImpl = {
2491
2553
  name: "Suspense",
@@ -3020,7 +3082,7 @@ var VueRuntimeDOM = (function (exports) {
3020
3082
  }
3021
3083
  if (isArray(s)) {
3022
3084
  const singleChild = filterSingleRoot(s);
3023
- if (!singleChild) {
3085
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3024
3086
  warn(`<Suspense> slots expect a single root node.`);
3025
3087
  }
3026
3088
  s = singleChild;
@@ -3170,6 +3232,7 @@ var VueRuntimeDOM = (function (exports) {
3170
3232
  let onCleanup = (fn) => {
3171
3233
  cleanup = effect.onStop = () => {
3172
3234
  callWithErrorHandling(fn, instance, 4);
3235
+ cleanup = effect.onStop = void 0;
3173
3236
  };
3174
3237
  };
3175
3238
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3641,7 +3704,11 @@ var VueRuntimeDOM = (function (exports) {
3641
3704
  }
3642
3705
  }
3643
3706
  function getKeepAliveChild(vnode) {
3644
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3707
+ return isKeepAlive(vnode) ? (
3708
+ // #7121 ensure get the child component subtree in case
3709
+ // it's been replaced during HMR
3710
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3711
+ ) : vnode;
3645
3712
  }
3646
3713
  function setTransitionHooks(vnode, hooks) {
3647
3714
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4119,61 +4186,6 @@ var VueRuntimeDOM = (function (exports) {
4119
4186
  injectHook("ec", hook, target);
4120
4187
  }
4121
4188
 
4122
- const COMPONENTS = "components";
4123
- const DIRECTIVES = "directives";
4124
- function resolveComponent(name, maybeSelfReference) {
4125
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4126
- }
4127
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4128
- function resolveDynamicComponent(component) {
4129
- if (isString(component)) {
4130
- return resolveAsset(COMPONENTS, component, false) || component;
4131
- } else {
4132
- return component || NULL_DYNAMIC_COMPONENT;
4133
- }
4134
- }
4135
- function resolveDirective(name) {
4136
- return resolveAsset(DIRECTIVES, name);
4137
- }
4138
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4139
- const instance = currentRenderingInstance || currentInstance;
4140
- if (instance) {
4141
- const Component = instance.type;
4142
- if (type === COMPONENTS) {
4143
- const selfName = getComponentName(
4144
- Component,
4145
- false
4146
- /* do not include inferred name to avoid breaking existing code */
4147
- );
4148
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4149
- return Component;
4150
- }
4151
- }
4152
- const res = (
4153
- // local registration
4154
- // check instance[type] first which is resolved for options API
4155
- resolve(instance[type] || Component[type], name) || // global registration
4156
- resolve(instance.appContext[type], name)
4157
- );
4158
- if (!res && maybeSelfReference) {
4159
- return Component;
4160
- }
4161
- if (warnMissing && !res) {
4162
- const extra = type === COMPONENTS ? `
4163
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4164
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4165
- }
4166
- return res;
4167
- } else {
4168
- warn(
4169
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4170
- );
4171
- }
4172
- }
4173
- function resolve(registry, name) {
4174
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4175
- }
4176
-
4177
4189
  function renderList(source, renderItem, cache, index) {
4178
4190
  let ret;
4179
4191
  const cached = cache && cache[index];
@@ -5693,6 +5705,9 @@ If you want to remount the same app, move your app creation logic into a factory
5693
5705
  };
5694
5706
  }
5695
5707
  function getInvalidTypeMessage(name, value, expectedTypes) {
5708
+ if (expectedTypes.length === 0) {
5709
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5710
+ }
5696
5711
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5697
5712
  const expectedType = expectedTypes[0];
5698
5713
  const receivedType = toRawType(value);
@@ -5962,6 +5977,20 @@ If you want to remount the same app, move your app creation logic into a factory
5962
5977
  const { type, ref, shapeFlag, patchFlag } = vnode;
5963
5978
  let domType = node.nodeType;
5964
5979
  vnode.el = node;
5980
+ {
5981
+ if (!("__vnode" in node)) {
5982
+ Object.defineProperty(node, "__vnode", {
5983
+ value: vnode,
5984
+ enumerable: false
5985
+ });
5986
+ }
5987
+ if (!("__vueParentComponent" in node)) {
5988
+ Object.defineProperty(node, "__vueParentComponent", {
5989
+ value: parentComponent,
5990
+ enumerable: false
5991
+ });
5992
+ }
5993
+ }
5965
5994
  if (patchFlag === -2) {
5966
5995
  optimized = false;
5967
5996
  vnode.dynamicChildren = null;
@@ -5992,15 +6021,15 @@ If you want to remount the same app, move your app creation logic into a factory
5992
6021
  }
5993
6022
  break;
5994
6023
  case Comment:
5995
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
5996
- if (node.tagName.toLowerCase() === "template") {
5997
- const content = vnode.el.content.firstChild;
5998
- replaceNode(content, node, parentComponent);
5999
- vnode.el = node = content;
6000
- nextNode = nextSibling(node);
6001
- } else {
6002
- nextNode = onMismatch();
6003
- }
6024
+ if (isTemplateNode(node)) {
6025
+ nextNode = nextSibling(node);
6026
+ replaceNode(
6027
+ vnode.el = node.content.firstChild,
6028
+ node,
6029
+ parentComponent
6030
+ );
6031
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6032
+ nextNode = onMismatch();
6004
6033
  } else {
6005
6034
  nextNode = nextSibling(node);
6006
6035
  }
@@ -6123,15 +6152,16 @@ If you want to remount the same app, move your app creation logic into a factory
6123
6152
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6124
6153
  optimized = optimized || !!vnode.dynamicChildren;
6125
6154
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6126
- const forcePatchValue = type === "input" && dirs || type === "option";
6155
+ const forcePatch = type === "input" || type === "option";
6127
6156
  {
6128
6157
  if (dirs) {
6129
6158
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6130
6159
  }
6131
6160
  if (props) {
6132
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6161
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6133
6162
  for (const key in props) {
6134
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6163
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6164
+ key[0] === ".") {
6135
6165
  patchProp(
6136
6166
  el,
6137
6167
  key,
@@ -6344,8 +6374,7 @@ If you want to remount the same app, move your app creation logic into a factory
6344
6374
  let parent = parentComponent;
6345
6375
  while (parent) {
6346
6376
  if (parent.vnode.el === oldNode) {
6347
- parent.vnode.el = newNode;
6348
- parent.subTree.el = newNode;
6377
+ parent.vnode.el = parent.subTree.el = newNode;
6349
6378
  }
6350
6379
  parent = parent.parent;
6351
6380
  }
@@ -7895,6 +7924,7 @@ If you want to remount the same app, move your app creation logic into a factory
7895
7924
  }
7896
7925
  };
7897
7926
  const TeleportImpl = {
7927
+ name: "Teleport",
7898
7928
  __isTeleport: true,
7899
7929
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7900
7930
  const {
@@ -8316,7 +8346,7 @@ If you want to remount the same app, move your app creation logic into a factory
8316
8346
  if (shapeFlag & 4 && isProxy(type)) {
8317
8347
  type = toRaw(type);
8318
8348
  warn(
8319
- `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
8349
+ `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
8320
8350
  `
8321
8351
  Component that was made reactive: `,
8322
8352
  type
@@ -9131,7 +9161,7 @@ Component that was made reactive: `,
9131
9161
  return true;
9132
9162
  }
9133
9163
 
9134
- const version = "3.4.0-alpha.1";
9164
+ const version = "3.4.0-alpha.2";
9135
9165
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9136
9166
  const ssrUtils = null;
9137
9167
  const resolveFilter = null;
@@ -10265,21 +10295,20 @@ Component that was made reactive: `,
10265
10295
  el[assignKey] = getModelAssigner(vnode);
10266
10296
  if (el.composing)
10267
10297
  return;
10298
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10299
+ const newValue = value == null ? "" : value;
10300
+ if (elValue === newValue) {
10301
+ return;
10302
+ }
10268
10303
  if (document.activeElement === el && el.type !== "range") {
10269
10304
  if (lazy) {
10270
10305
  return;
10271
10306
  }
10272
- if (trim && el.value.trim() === value) {
10273
- return;
10274
- }
10275
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10307
+ if (trim && el.value.trim() === newValue) {
10276
10308
  return;
10277
10309
  }
10278
10310
  }
10279
- const newValue = value == null ? "" : value;
10280
- if (el.value !== newValue) {
10281
- el.value = newValue;
10282
- }
10311
+ el.value = newValue;
10283
10312
  }
10284
10313
  };
10285
10314
  const vModelCheckbox = {