@vue/runtime-dom 3.4.0-beta.1 → 3.4.0-beta.3

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");
@@ -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);
@@ -2575,6 +2575,8 @@ var VueRuntimeDOM = (function (exports) {
2575
2575
  return false;
2576
2576
  }
2577
2577
  function updateHOCHostEl({ vnode, parent }, el) {
2578
+ if (!el)
2579
+ return;
2578
2580
  while (parent) {
2579
2581
  const root = parent.subTree;
2580
2582
  if (root.suspense && root.suspense.activeBranch === vnode) {
@@ -4719,24 +4721,30 @@ If this is a native custom element, make sure to exclude it from component resol
4719
4721
  warn(`useModel() called with prop "${name}" which is not declared.`);
4720
4722
  return ref();
4721
4723
  }
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;
4724
+ return customRef((track, trigger) => {
4725
+ let localValue;
4726
+ watchSyncEffect(() => {
4727
+ const propValue = props[name];
4728
+ if (hasChanged(localValue, propValue)) {
4729
+ localValue = propValue;
4735
4730
  trigger();
4736
4731
  }
4737
- i.emit(`update:${name}`, value);
4738
- }
4739
- }));
4732
+ });
4733
+ return {
4734
+ get() {
4735
+ track();
4736
+ return localValue;
4737
+ },
4738
+ set(value) {
4739
+ const rawProps = i.vnode.props;
4740
+ if (!(rawProps && name in rawProps) && hasChanged(value, localValue)) {
4741
+ localValue = value;
4742
+ trigger();
4743
+ }
4744
+ i.emit(`update:${name}`, value);
4745
+ }
4746
+ };
4747
+ });
4740
4748
  }
4741
4749
  function getContext() {
4742
4750
  const i = getCurrentInstance();
@@ -9365,7 +9373,7 @@ Component that was made reactive: `,
9365
9373
  return true;
9366
9374
  }
9367
9375
 
9368
- const version = "3.4.0-beta.1";
9376
+ const version = "3.4.0-beta.3";
9369
9377
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9370
9378
  const ssrUtils = null;
9371
9379
  const resolveFilter = null;
@@ -9763,6 +9771,69 @@ Component that was made reactive: `,
9763
9771
  el.style.display = value ? el[vShowOldKey] : "none";
9764
9772
  }
9765
9773
 
9774
+ const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
9775
+ function useCssVars(getter) {
9776
+ const instance = getCurrentInstance();
9777
+ if (!instance) {
9778
+ warn(`useCssVars is called without current active component instance.`);
9779
+ return;
9780
+ }
9781
+ const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
9782
+ Array.from(
9783
+ document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
9784
+ ).forEach((node) => setVarsOnNode(node, vars));
9785
+ };
9786
+ const setVars = () => {
9787
+ const vars = getter(instance.proxy);
9788
+ setVarsOnVNode(instance.subTree, vars);
9789
+ updateTeleports(vars);
9790
+ };
9791
+ watchPostEffect(setVars);
9792
+ onMounted(() => {
9793
+ const ob = new MutationObserver(setVars);
9794
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
9795
+ onUnmounted(() => ob.disconnect());
9796
+ });
9797
+ }
9798
+ function setVarsOnVNode(vnode, vars) {
9799
+ if (vnode.shapeFlag & 128) {
9800
+ const suspense = vnode.suspense;
9801
+ vnode = suspense.activeBranch;
9802
+ if (suspense.pendingBranch && !suspense.isHydrating) {
9803
+ suspense.effects.push(() => {
9804
+ setVarsOnVNode(suspense.activeBranch, vars);
9805
+ });
9806
+ }
9807
+ }
9808
+ while (vnode.component) {
9809
+ vnode = vnode.component.subTree;
9810
+ }
9811
+ if (vnode.shapeFlag & 1 && vnode.el) {
9812
+ setVarsOnNode(vnode.el, vars);
9813
+ } else if (vnode.type === Fragment) {
9814
+ vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9815
+ } else if (vnode.type === Static) {
9816
+ let { el, anchor } = vnode;
9817
+ while (el) {
9818
+ setVarsOnNode(el, vars);
9819
+ if (el === anchor)
9820
+ break;
9821
+ el = el.nextSibling;
9822
+ }
9823
+ }
9824
+ }
9825
+ function setVarsOnNode(el, vars) {
9826
+ if (el.nodeType === 1) {
9827
+ const style = el.style;
9828
+ let cssText = "";
9829
+ for (const key in vars) {
9830
+ style.setProperty(`--${key}`, vars[key]);
9831
+ cssText += `--${key}: ${vars[key]};`;
9832
+ }
9833
+ style[CSS_VAR_TEXT] = cssText;
9834
+ }
9835
+ }
9836
+
9766
9837
  function patchStyle(el, prev, next) {
9767
9838
  const style = el.style;
9768
9839
  const isCssString = isString(next);
@@ -9781,6 +9852,10 @@ Component that was made reactive: `,
9781
9852
  const currentDisplay = style.display;
9782
9853
  if (isCssString) {
9783
9854
  if (prev !== next) {
9855
+ const cssVarText = style[CSS_VAR_TEXT];
9856
+ if (cssVarText) {
9857
+ next += ";" + cssVarText;
9858
+ }
9784
9859
  style.cssText = next;
9785
9860
  }
9786
9861
  } else if (prev) {
@@ -10276,65 +10351,6 @@ Component that was made reactive: `,
10276
10351
  }
10277
10352
  }
10278
10353
 
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
10354
  const positionMap = /* @__PURE__ */ new WeakMap();
10339
10355
  const newPositionMap = /* @__PURE__ */ new WeakMap();
10340
10356
  const moveCbKey = Symbol("_moveCb");