@vue/runtime-dom 3.5.0-alpha.2 → 3.5.0-alpha.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,11 +1,11 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.0-alpha.2
2
+ * @vue/runtime-dom v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
6
  import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, getCurrentInstance, warn, onMounted, watchPostEffect, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
7
7
  export * from '@vue/runtime-core';
8
- import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isFunction, NOOP, isOn, isModelListener, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
8
+ import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, includeBooleanAttr, isSymbol, isSpecialBooleanAttr, isFunction, NOOP, isOn, isModelListener, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
9
9
 
10
10
  const svgNS = "http://www.w3.org/2000/svg";
11
11
  const mathmlNS = "http://www.w3.org/1998/Math/MathML";
@@ -22,7 +22,7 @@ const nodeOps = {
22
22
  }
23
23
  },
24
24
  createElement: (tag, namespace, is, props) => {
25
- const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
25
+ const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
26
26
  if (tag === "select" && props && props.multiple != null) {
27
27
  el.setAttribute("multiple", props.multiple);
28
28
  }
@@ -51,8 +51,7 @@ const nodeOps = {
51
51
  if (start && (start === end || start.nextSibling)) {
52
52
  while (true) {
53
53
  parent.insertBefore(start.cloneNode(true), anchor);
54
- if (start === end || !(start = start.nextSibling))
55
- break;
54
+ if (start === end || !(start = start.nextSibling)) break;
56
55
  }
57
56
  } else {
58
57
  templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
@@ -336,8 +335,7 @@ function getTimeout(delays, durations) {
336
335
  return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
337
336
  }
338
337
  function toMs(s) {
339
- if (s === "auto")
340
- return 0;
338
+ if (s === "auto") return 0;
341
339
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
342
340
  }
343
341
  function forceReflow() {
@@ -375,8 +373,7 @@ const vShow = {
375
373
  }
376
374
  },
377
375
  updated(el, { value, oldValue }, { transition }) {
378
- if (!value === !oldValue)
379
- return;
376
+ if (!value === !oldValue) return;
380
377
  if (transition) {
381
378
  if (value) {
382
379
  transition.beforeEnter(el);
@@ -458,8 +455,7 @@ function setVarsOnVNode(vnode, vars) {
458
455
  let { el, anchor } = vnode;
459
456
  while (el) {
460
457
  setVarsOnNode(el, vars);
461
- if (el === anchor)
462
- break;
458
+ if (el === anchor) break;
463
459
  el = el.nextSibling;
464
460
  }
465
461
  }
@@ -531,8 +527,7 @@ function setStyle(style, name, val) {
531
527
  if (isArray(val)) {
532
528
  val.forEach((v) => setStyle(style, name, v));
533
529
  } else {
534
- if (val == null)
535
- val = "";
530
+ if (val == null) val = "";
536
531
  if (!!(process.env.NODE_ENV !== "production")) {
537
532
  if (semicolonRE.test(val)) {
538
533
  warn(
@@ -578,7 +573,7 @@ function autoPrefix(style, rawName) {
578
573
  }
579
574
 
580
575
  const xlinkNS = "http://www.w3.org/1999/xlink";
581
- function patchAttr(el, key, value, isSVG, instance) {
576
+ function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
582
577
  if (isSVG && key.startsWith("xlink:")) {
583
578
  if (value == null) {
584
579
  el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
@@ -586,28 +581,28 @@ function patchAttr(el, key, value, isSVG, instance) {
586
581
  el.setAttributeNS(xlinkNS, key, value);
587
582
  }
588
583
  } else {
589
- const isBoolean = isSpecialBooleanAttr(key);
590
584
  if (value == null || isBoolean && !includeBooleanAttr(value)) {
591
585
  el.removeAttribute(key);
592
586
  } else {
593
- el.setAttribute(key, isBoolean ? "" : value);
587
+ el.setAttribute(
588
+ key,
589
+ isBoolean ? "" : isSymbol(value) ? String(value) : value
590
+ );
594
591
  }
595
592
  }
596
593
  }
597
594
 
598
- function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
595
+ function patchDOMProp(el, key, value, parentComponent) {
599
596
  if (key === "innerHTML" || key === "textContent") {
600
- if (prevChildren) {
601
- unmountChildren(prevChildren, parentComponent, parentSuspense);
602
- }
603
- el[key] = value == null ? "" : value;
597
+ if (value == null) return;
598
+ el[key] = value;
604
599
  return;
605
600
  }
606
601
  const tag = el.tagName;
607
602
  if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
608
603
  !tag.includes("-")) {
609
604
  const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
610
- const newValue = value == null ? "" : value;
605
+ const newValue = value == null ? "" : String(value);
611
606
  if (oldValue !== newValue || !("_value" in el)) {
612
607
  el.value = newValue;
613
608
  }
@@ -731,7 +726,7 @@ function patchStopImmediatePropagation(e, value) {
731
726
 
732
727
  const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
733
728
  key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
734
- const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
729
+ const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
735
730
  const isSVG = namespace === "svg";
736
731
  if (key === "class") {
737
732
  patchClass(el, nextValue, isSVG);
@@ -742,15 +737,10 @@ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, paren
742
737
  patchEvent(el, key, prevValue, nextValue, parentComponent);
743
738
  }
744
739
  } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
745
- patchDOMProp(
746
- el,
747
- key,
748
- nextValue,
749
- prevChildren,
750
- parentComponent,
751
- parentSuspense,
752
- unmountChildren
753
- );
740
+ patchDOMProp(el, key, nextValue);
741
+ if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
742
+ patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
743
+ }
754
744
  } else {
755
745
  if (key === "true-value") {
756
746
  el._trueValue = nextValue;
@@ -796,8 +786,8 @@ function shouldSetAsProp(el, key, value, isSVG) {
796
786
 
797
787
  /*! #__NO_SIDE_EFFECTS__ */
798
788
  // @__NO_SIDE_EFFECTS__
799
- function defineCustomElement(options, hydrate2) {
800
- const Comp = defineComponent(options);
789
+ function defineCustomElement(options, extraOptions, hydrate2) {
790
+ const Comp = defineComponent(options, extraOptions);
801
791
  class VueCustomElement extends VueElement {
802
792
  constructor(initialProps) {
803
793
  super(Comp, initialProps, hydrate2);
@@ -807,8 +797,8 @@ function defineCustomElement(options, hydrate2) {
807
797
  return VueCustomElement;
808
798
  }
809
799
  /*! #__NO_SIDE_EFFECTS__ */
810
- const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
811
- return /* @__PURE__ */ defineCustomElement(options, hydrate);
800
+ const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
801
+ return /* @__PURE__ */ defineCustomElement(options, extraOptions, hydrate);
812
802
  };
813
803
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
814
804
  };
@@ -851,12 +841,12 @@ class VueElement extends BaseClass {
851
841
  }
852
842
  disconnectedCallback() {
853
843
  this._connected = false;
854
- if (this._ob) {
855
- this._ob.disconnect();
856
- this._ob = null;
857
- }
858
844
  nextTick(() => {
859
845
  if (!this._connected) {
846
+ if (this._ob) {
847
+ this._ob.disconnect();
848
+ this._ob = null;
849
+ }
860
850
  render(null, this.shadowRoot);
861
851
  this._instance = null;
862
852
  }
@@ -1192,8 +1182,7 @@ const vModelText = {
1192
1182
  el[assignKey] = getModelAssigner(vnode);
1193
1183
  const castToNumber = number || vnode.props && vnode.props.type === "number";
1194
1184
  addEventListener(el, lazy ? "change" : "input", (e) => {
1195
- if (e.target.composing)
1196
- return;
1185
+ if (e.target.composing) return;
1197
1186
  let domValue = el.value;
1198
1187
  if (trim) {
1199
1188
  domValue = domValue.trim();
@@ -1218,17 +1207,16 @@ const vModelText = {
1218
1207
  mounted(el, { value }) {
1219
1208
  el.value = value == null ? "" : value;
1220
1209
  },
1221
- beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
1210
+ beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
1222
1211
  el[assignKey] = getModelAssigner(vnode);
1223
- if (el.composing)
1224
- return;
1212
+ if (el.composing) return;
1225
1213
  const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
1226
1214
  const newValue = value == null ? "" : value;
1227
1215
  if (elValue === newValue) {
1228
1216
  return;
1229
1217
  }
1230
1218
  if (document.activeElement === el && el.type !== "range") {
1231
- if (lazy) {
1219
+ if (lazy && value === oldValue) {
1232
1220
  return;
1233
1221
  }
1234
1222
  if (trim && el.value.trim() === newValue) {
@@ -1360,8 +1348,7 @@ function setSelected(el, value, number) {
1360
1348
  option.selected = value.has(optionValue);
1361
1349
  }
1362
1350
  } else if (looseEqual(getValue(option), value)) {
1363
- if (el.selectedIndex !== i)
1364
- el.selectedIndex = i;
1351
+ if (el.selectedIndex !== i) el.selectedIndex = i;
1365
1352
  return;
1366
1353
  }
1367
1354
  }
@@ -1470,8 +1457,7 @@ const withModifiers = (fn, modifiers) => {
1470
1457
  return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
1471
1458
  for (let i = 0; i < modifiers.length; i++) {
1472
1459
  const guard = modifierGuards[modifiers[i]];
1473
- if (guard && guard(event, modifiers))
1474
- return;
1460
+ if (guard && guard(event, modifiers)) return;
1475
1461
  }
1476
1462
  return fn(event, ...args);
1477
1463
  });
@@ -1527,8 +1513,7 @@ const createApp = (...args) => {
1527
1513
  const { mount } = app;
1528
1514
  app.mount = (containerOrSelector) => {
1529
1515
  const container = normalizeContainer(containerOrSelector);
1530
- if (!container)
1531
- return;
1516
+ if (!container) return;
1532
1517
  const component = app._component;
1533
1518
  if (!isFunction(component) && !component.render && !component.template) {
1534
1519
  component.template = container.innerHTML;