@vue/runtime-dom 3.4.0-beta.2 → 3.4.0-beta.4

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.
@@ -1,4 +1,4 @@
1
- import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
1
+ import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, getCurrentInstance, warn, watchPostEffect, onMounted, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
2
2
  export * from '@vue/runtime-core';
3
3
  import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
4
4
 
@@ -400,6 +400,69 @@ function initVShowForSSR() {
400
400
  };
401
401
  }
402
402
 
403
+ const CSS_VAR_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? "CSS_VAR_TEXT" : "");
404
+ function useCssVars(getter) {
405
+ const instance = getCurrentInstance();
406
+ if (!instance) {
407
+ !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
408
+ return;
409
+ }
410
+ const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
411
+ Array.from(
412
+ document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
413
+ ).forEach((node) => setVarsOnNode(node, vars));
414
+ };
415
+ const setVars = () => {
416
+ const vars = getter(instance.proxy);
417
+ setVarsOnVNode(instance.subTree, vars);
418
+ updateTeleports(vars);
419
+ };
420
+ watchPostEffect(setVars);
421
+ onMounted(() => {
422
+ const ob = new MutationObserver(setVars);
423
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
424
+ onUnmounted(() => ob.disconnect());
425
+ });
426
+ }
427
+ function setVarsOnVNode(vnode, vars) {
428
+ if (vnode.shapeFlag & 128) {
429
+ const suspense = vnode.suspense;
430
+ vnode = suspense.activeBranch;
431
+ if (suspense.pendingBranch && !suspense.isHydrating) {
432
+ suspense.effects.push(() => {
433
+ setVarsOnVNode(suspense.activeBranch, vars);
434
+ });
435
+ }
436
+ }
437
+ while (vnode.component) {
438
+ vnode = vnode.component.subTree;
439
+ }
440
+ if (vnode.shapeFlag & 1 && vnode.el) {
441
+ setVarsOnNode(vnode.el, vars);
442
+ } else if (vnode.type === Fragment) {
443
+ vnode.children.forEach((c) => setVarsOnVNode(c, vars));
444
+ } else if (vnode.type === Static) {
445
+ let { el, anchor } = vnode;
446
+ while (el) {
447
+ setVarsOnNode(el, vars);
448
+ if (el === anchor)
449
+ break;
450
+ el = el.nextSibling;
451
+ }
452
+ }
453
+ }
454
+ function setVarsOnNode(el, vars) {
455
+ if (el.nodeType === 1) {
456
+ const style = el.style;
457
+ let cssText = "";
458
+ for (const key in vars) {
459
+ style.setProperty(`--${key}`, vars[key]);
460
+ cssText += `--${key}: ${vars[key]};`;
461
+ }
462
+ style[CSS_VAR_TEXT] = cssText;
463
+ }
464
+ }
465
+
403
466
  function patchStyle(el, prev, next) {
404
467
  const style = el.style;
405
468
  const isCssString = isString(next);
@@ -418,6 +481,10 @@ function patchStyle(el, prev, next) {
418
481
  const currentDisplay = style.display;
419
482
  if (isCssString) {
420
483
  if (prev !== next) {
484
+ const cssVarText = style[CSS_VAR_TEXT];
485
+ if (cssVarText) {
486
+ next += ";" + cssVarText;
487
+ }
421
488
  style.cssText = next;
422
489
  }
423
490
  } else if (prev) {
@@ -925,65 +992,6 @@ function useCssModule(name = "$style") {
925
992
  }
926
993
  }
927
994
 
928
- function useCssVars(getter) {
929
- const instance = getCurrentInstance();
930
- if (!instance) {
931
- !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
932
- return;
933
- }
934
- const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
935
- Array.from(
936
- document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
937
- ).forEach((node) => setVarsOnNode(node, vars));
938
- };
939
- const setVars = () => {
940
- const vars = getter(instance.proxy);
941
- setVarsOnVNode(instance.subTree, vars);
942
- updateTeleports(vars);
943
- };
944
- watchPostEffect(setVars);
945
- onMounted(() => {
946
- const ob = new MutationObserver(setVars);
947
- ob.observe(instance.subTree.el.parentNode, { childList: true });
948
- onUnmounted(() => ob.disconnect());
949
- });
950
- }
951
- function setVarsOnVNode(vnode, vars) {
952
- if (vnode.shapeFlag & 128) {
953
- const suspense = vnode.suspense;
954
- vnode = suspense.activeBranch;
955
- if (suspense.pendingBranch && !suspense.isHydrating) {
956
- suspense.effects.push(() => {
957
- setVarsOnVNode(suspense.activeBranch, vars);
958
- });
959
- }
960
- }
961
- while (vnode.component) {
962
- vnode = vnode.component.subTree;
963
- }
964
- if (vnode.shapeFlag & 1 && vnode.el) {
965
- setVarsOnNode(vnode.el, vars);
966
- } else if (vnode.type === Fragment) {
967
- vnode.children.forEach((c) => setVarsOnVNode(c, vars));
968
- } else if (vnode.type === Static) {
969
- let { el, anchor } = vnode;
970
- while (el) {
971
- setVarsOnNode(el, vars);
972
- if (el === anchor)
973
- break;
974
- el = el.nextSibling;
975
- }
976
- }
977
- }
978
- function setVarsOnNode(el, vars) {
979
- if (el.nodeType === 1) {
980
- const style = el.style;
981
- for (const key in vars) {
982
- style.setProperty(`--${key}`, vars[key]);
983
- }
984
- }
985
- }
986
-
987
995
  const positionMap = /* @__PURE__ */ new WeakMap();
988
996
  const newPositionMap = /* @__PURE__ */ new WeakMap();
989
997
  const moveCbKey = Symbol("_moveCb");
@@ -1391,7 +1399,9 @@ const modifierGuards = {
1391
1399
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1392
1400
  };
1393
1401
  const withModifiers = (fn, modifiers) => {
1394
- return fn._withMods || (fn._withMods = (event, ...args) => {
1402
+ const cache = fn._withMods || (fn._withMods = {});
1403
+ const cacheKey = modifiers.join(".");
1404
+ return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
1395
1405
  for (let i = 0; i < modifiers.length; i++) {
1396
1406
  const guard = modifierGuards[modifiers[i]];
1397
1407
  if (guard && guard(event, modifiers))
@@ -1410,7 +1420,9 @@ const keyNames = {
1410
1420
  delete: "backspace"
1411
1421
  };
1412
1422
  const withKeys = (fn, modifiers) => {
1413
- return fn._withKeys || (fn._withKeys = (event) => {
1423
+ const cache = fn._withKeys || (fn._withKeys = {});
1424
+ const cacheKey = modifiers.join(".");
1425
+ return cache[cacheKey] || (cache[cacheKey] = (event) => {
1414
1426
  if (!("key" in event)) {
1415
1427
  return;
1416
1428
  }
@@ -179,7 +179,7 @@ var VueRuntimeDOM = (function (exports) {
179
179
 
180
180
  const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
181
181
  const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
182
- const MATH_TAGS = "math,maction,annotation,annotation-xml,menclose,merror,mfenced,mfrac,mi,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,semantics,mspace,msqrt,mstyle,msub,msup,msubsup,mtable,mtd,mtext,mtr,munder,munderover";
182
+ const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
183
183
  const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
184
184
  const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
185
185
  const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
@@ -1896,8 +1896,10 @@ var VueRuntimeDOM = (function (exports) {
1896
1896
  if (count > RECURSION_LIMIT) {
1897
1897
  const instance = fn.ownerInstance;
1898
1898
  const componentName = instance && getComponentName(instance.type);
1899
- warn(
1900
- `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
1899
+ handleError(
1900
+ `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
1901
+ null,
1902
+ 10
1901
1903
  );
1902
1904
  return true;
1903
1905
  } else {
@@ -2575,6 +2577,8 @@ var VueRuntimeDOM = (function (exports) {
2575
2577
  return false;
2576
2578
  }
2577
2579
  function updateHOCHostEl({ vnode, parent }, el) {
2580
+ if (!el)
2581
+ return;
2578
2582
  while (parent) {
2579
2583
  const root = parent.subTree;
2580
2584
  if (root.suspense && root.suspense.activeBranch === vnode) {
@@ -4719,24 +4723,30 @@ If this is a native custom element, make sure to exclude it from component resol
4719
4723
  warn(`useModel() called with prop "${name}" which is not declared.`);
4720
4724
  return ref();
4721
4725
  }
4722
- let localValue;
4723
- watchSyncEffect(() => {
4724
- localValue = props[name];
4725
- });
4726
- return customRef((track, trigger) => ({
4727
- get() {
4728
- track();
4729
- return localValue;
4730
- },
4731
- set(value) {
4732
- const rawProps = i.vnode.props;
4733
- if (!(rawProps && name in rawProps) && hasChanged(value, localValue)) {
4734
- localValue = value;
4726
+ return customRef((track, trigger) => {
4727
+ let localValue;
4728
+ watchSyncEffect(() => {
4729
+ const propValue = props[name];
4730
+ if (hasChanged(localValue, propValue)) {
4731
+ localValue = propValue;
4735
4732
  trigger();
4736
4733
  }
4737
- i.emit(`update:${name}`, value);
4738
- }
4739
- }));
4734
+ });
4735
+ return {
4736
+ get() {
4737
+ track();
4738
+ return localValue;
4739
+ },
4740
+ set(value) {
4741
+ const rawProps = i.vnode.props;
4742
+ if (!(rawProps && name in rawProps) && hasChanged(value, localValue)) {
4743
+ localValue = value;
4744
+ trigger();
4745
+ }
4746
+ i.emit(`update:${name}`, value);
4747
+ }
4748
+ };
4749
+ });
4740
4750
  }
4741
4751
  function getContext() {
4742
4752
  const i = getCurrentInstance();
@@ -6502,7 +6512,7 @@ Server rendered element contains fewer child nodes than client vdom.`
6502
6512
  let actual;
6503
6513
  let expected;
6504
6514
  if (key === "class") {
6505
- actual = el.className;
6515
+ actual = el.getAttribute("class");
6506
6516
  expected = normalizeClass(clientValue);
6507
6517
  if (actual !== expected) {
6508
6518
  mismatchType = mismatchKey = `class`;
@@ -9365,7 +9375,7 @@ Component that was made reactive: `,
9365
9375
  return true;
9366
9376
  }
9367
9377
 
9368
- const version = "3.4.0-beta.2";
9378
+ const version = "3.4.0-beta.4";
9369
9379
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9370
9380
  const ssrUtils = null;
9371
9381
  const resolveFilter = null;
@@ -9763,6 +9773,69 @@ Component that was made reactive: `,
9763
9773
  el.style.display = value ? el[vShowOldKey] : "none";
9764
9774
  }
9765
9775
 
9776
+ const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
9777
+ function useCssVars(getter) {
9778
+ const instance = getCurrentInstance();
9779
+ if (!instance) {
9780
+ warn(`useCssVars is called without current active component instance.`);
9781
+ return;
9782
+ }
9783
+ const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
9784
+ Array.from(
9785
+ document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
9786
+ ).forEach((node) => setVarsOnNode(node, vars));
9787
+ };
9788
+ const setVars = () => {
9789
+ const vars = getter(instance.proxy);
9790
+ setVarsOnVNode(instance.subTree, vars);
9791
+ updateTeleports(vars);
9792
+ };
9793
+ watchPostEffect(setVars);
9794
+ onMounted(() => {
9795
+ const ob = new MutationObserver(setVars);
9796
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
9797
+ onUnmounted(() => ob.disconnect());
9798
+ });
9799
+ }
9800
+ function setVarsOnVNode(vnode, vars) {
9801
+ if (vnode.shapeFlag & 128) {
9802
+ const suspense = vnode.suspense;
9803
+ vnode = suspense.activeBranch;
9804
+ if (suspense.pendingBranch && !suspense.isHydrating) {
9805
+ suspense.effects.push(() => {
9806
+ setVarsOnVNode(suspense.activeBranch, vars);
9807
+ });
9808
+ }
9809
+ }
9810
+ while (vnode.component) {
9811
+ vnode = vnode.component.subTree;
9812
+ }
9813
+ if (vnode.shapeFlag & 1 && vnode.el) {
9814
+ setVarsOnNode(vnode.el, vars);
9815
+ } else if (vnode.type === Fragment) {
9816
+ vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9817
+ } else if (vnode.type === Static) {
9818
+ let { el, anchor } = vnode;
9819
+ while (el) {
9820
+ setVarsOnNode(el, vars);
9821
+ if (el === anchor)
9822
+ break;
9823
+ el = el.nextSibling;
9824
+ }
9825
+ }
9826
+ }
9827
+ function setVarsOnNode(el, vars) {
9828
+ if (el.nodeType === 1) {
9829
+ const style = el.style;
9830
+ let cssText = "";
9831
+ for (const key in vars) {
9832
+ style.setProperty(`--${key}`, vars[key]);
9833
+ cssText += `--${key}: ${vars[key]};`;
9834
+ }
9835
+ style[CSS_VAR_TEXT] = cssText;
9836
+ }
9837
+ }
9838
+
9766
9839
  function patchStyle(el, prev, next) {
9767
9840
  const style = el.style;
9768
9841
  const isCssString = isString(next);
@@ -9781,6 +9854,10 @@ Component that was made reactive: `,
9781
9854
  const currentDisplay = style.display;
9782
9855
  if (isCssString) {
9783
9856
  if (prev !== next) {
9857
+ const cssVarText = style[CSS_VAR_TEXT];
9858
+ if (cssVarText) {
9859
+ next += ";" + cssVarText;
9860
+ }
9784
9861
  style.cssText = next;
9785
9862
  }
9786
9863
  } else if (prev) {
@@ -10276,65 +10353,6 @@ Component that was made reactive: `,
10276
10353
  }
10277
10354
  }
10278
10355
 
10279
- function useCssVars(getter) {
10280
- const instance = getCurrentInstance();
10281
- if (!instance) {
10282
- warn(`useCssVars is called without current active component instance.`);
10283
- return;
10284
- }
10285
- const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
10286
- Array.from(
10287
- document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
10288
- ).forEach((node) => setVarsOnNode(node, vars));
10289
- };
10290
- const setVars = () => {
10291
- const vars = getter(instance.proxy);
10292
- setVarsOnVNode(instance.subTree, vars);
10293
- updateTeleports(vars);
10294
- };
10295
- watchPostEffect(setVars);
10296
- onMounted(() => {
10297
- const ob = new MutationObserver(setVars);
10298
- ob.observe(instance.subTree.el.parentNode, { childList: true });
10299
- onUnmounted(() => ob.disconnect());
10300
- });
10301
- }
10302
- function setVarsOnVNode(vnode, vars) {
10303
- if (vnode.shapeFlag & 128) {
10304
- const suspense = vnode.suspense;
10305
- vnode = suspense.activeBranch;
10306
- if (suspense.pendingBranch && !suspense.isHydrating) {
10307
- suspense.effects.push(() => {
10308
- setVarsOnVNode(suspense.activeBranch, vars);
10309
- });
10310
- }
10311
- }
10312
- while (vnode.component) {
10313
- vnode = vnode.component.subTree;
10314
- }
10315
- if (vnode.shapeFlag & 1 && vnode.el) {
10316
- setVarsOnNode(vnode.el, vars);
10317
- } else if (vnode.type === Fragment) {
10318
- vnode.children.forEach((c) => setVarsOnVNode(c, vars));
10319
- } else if (vnode.type === Static) {
10320
- let { el, anchor } = vnode;
10321
- while (el) {
10322
- setVarsOnNode(el, vars);
10323
- if (el === anchor)
10324
- break;
10325
- el = el.nextSibling;
10326
- }
10327
- }
10328
- }
10329
- function setVarsOnNode(el, vars) {
10330
- if (el.nodeType === 1) {
10331
- const style = el.style;
10332
- for (const key in vars) {
10333
- style.setProperty(`--${key}`, vars[key]);
10334
- }
10335
- }
10336
- }
10337
-
10338
10356
  const positionMap = /* @__PURE__ */ new WeakMap();
10339
10357
  const newPositionMap = /* @__PURE__ */ new WeakMap();
10340
10358
  const moveCbKey = Symbol("_moveCb");
@@ -10708,7 +10726,9 @@ Component that was made reactive: `,
10708
10726
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
10709
10727
  };
10710
10728
  const withModifiers = (fn, modifiers) => {
10711
- return fn._withMods || (fn._withMods = (event, ...args) => {
10729
+ const cache = fn._withMods || (fn._withMods = {});
10730
+ const cacheKey = modifiers.join(".");
10731
+ return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
10712
10732
  for (let i = 0; i < modifiers.length; i++) {
10713
10733
  const guard = modifierGuards[modifiers[i]];
10714
10734
  if (guard && guard(event, modifiers))
@@ -10727,7 +10747,9 @@ Component that was made reactive: `,
10727
10747
  delete: "backspace"
10728
10748
  };
10729
10749
  const withKeys = (fn, modifiers) => {
10730
- return fn._withKeys || (fn._withKeys = (event) => {
10750
+ const cache = fn._withKeys || (fn._withKeys = {});
10751
+ const cacheKey = modifiers.join(".");
10752
+ return cache[cacheKey] || (cache[cacheKey] = (event) => {
10731
10753
  if (!("key" in event)) {
10732
10754
  return;
10733
10755
  }