@vue/runtime-dom 3.6.0-alpha.4 → 3.6.0-alpha.5

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,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-alpha.4
2
+ * @vue/runtime-dom v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -436,36 +436,20 @@ function initVShowForSSR() {
436
436
  const CSS_VAR_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? "CSS_VAR_TEXT" : "");
437
437
  function useCssVars(getter) {
438
438
  const instance = getCurrentInstance();
439
- if (!instance) {
440
- !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
441
- return;
442
- }
443
- const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
444
- Array.from(
445
- document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
446
- ).forEach((node) => setVarsOnNode(node, vars));
447
- };
448
- if (!!(process.env.NODE_ENV !== "production")) {
449
- instance.getCssVars = () => getter(instance.proxy);
450
- }
451
- const setVars = () => {
452
- const vars = getter(instance.proxy);
439
+ const getVars = () => getter(instance.proxy);
440
+ const setVars = (vars) => {
453
441
  if (instance.ce) {
454
442
  setVarsOnNode(instance.ce, vars);
455
443
  } else {
456
444
  setVarsOnVNode(instance.subTree, vars);
457
445
  }
458
- updateTeleports(vars);
459
446
  };
460
- onBeforeUpdate(() => {
461
- queuePostFlushCb(setVars);
462
- });
463
- onMounted(() => {
464
- watch(setVars, NOOP, { flush: "post" });
465
- const ob = new MutationObserver(setVars);
466
- ob.observe(instance.subTree.el.parentNode, { childList: true });
467
- onUnmounted(() => ob.disconnect());
468
- });
447
+ baseUseCssVars(
448
+ instance,
449
+ () => instance.subTree.el.parentNode,
450
+ getVars,
451
+ setVars
452
+ );
469
453
  }
470
454
  function setVarsOnVNode(vnode, vars) {
471
455
  if (vnode.shapeFlag & 128) {
@@ -493,6 +477,34 @@ function setVarsOnVNode(vnode, vars) {
493
477
  }
494
478
  }
495
479
  }
480
+ function baseUseCssVars(instance, getParentNode, getVars, setVars) {
481
+ if (!instance) {
482
+ !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
483
+ return;
484
+ }
485
+ if (!!(process.env.NODE_ENV !== "production")) {
486
+ instance.getCssVars = getVars;
487
+ }
488
+ const updateTeleports = instance.ut = (vars = getVars()) => {
489
+ Array.from(
490
+ document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
491
+ ).forEach((node) => setVarsOnNode(node, vars));
492
+ };
493
+ const applyCssCars = () => {
494
+ const vars = getVars();
495
+ setVars(vars);
496
+ updateTeleports(vars);
497
+ };
498
+ onBeforeUpdate(() => {
499
+ queuePostFlushCb(applyCssCars);
500
+ });
501
+ onMounted(() => {
502
+ watch(applyCssCars, NOOP, { flush: "post" });
503
+ const ob = new MutationObserver(applyCssCars);
504
+ ob.observe(getParentNode(), { childList: true });
505
+ onUnmounted(() => ob.disconnect());
506
+ });
507
+ }
496
508
  function setVarsOnNode(el, vars) {
497
509
  if (el.nodeType === 1) {
498
510
  const style = el.style;
@@ -1985,4 +1997,4 @@ const initDirectivesForSSR = () => {
1985
1997
  }
1986
1998
  } ;
1987
1999
 
1988
- export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, patchProp, patchStyle, render, resolveTransitionProps, shouldSetAsProp, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };
2000
+ export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, baseUseCssVars, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, patchProp, patchStyle, render, resolveTransitionProps, setVarsOnNode, shouldSetAsProp, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };