@vue/runtime-dom 3.6.0-rc.1 → 3.6.0-rc.11

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-rc.1
2
+ * @vue/runtime-dom v3.6.0-rc.11
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -13,7 +13,7 @@ let _vue_shared = require("@vue/shared");
13
13
  let policy = void 0;
14
14
  const tt = typeof window !== "undefined" && window.trustedTypes;
15
15
  if (tt) try {
16
- policy = /* @__PURE__ */ tt.createPolicy("vue", { createHTML: (val) => val });
16
+ policy = /*@__PURE__*/ tt.createPolicy("vue", { createHTML: (val) => val });
17
17
  } catch (e) {
18
18
  (0, _vue_runtime_core.warn)(`Error creating trusted types policy: ${e}`);
19
19
  }
@@ -21,7 +21,7 @@ const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) =>
21
21
  const svgNS = "http://www.w3.org/2000/svg";
22
22
  const mathmlNS = "http://www.w3.org/1998/Math/MathML";
23
23
  const doc = typeof document !== "undefined" ? document : null;
24
- const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
24
+ const templateContainer = doc && /*@__PURE__*/ doc.createElement("template");
25
25
  const nodeOps = {
26
26
  insert: (child, parent, anchor) => {
27
27
  parent.insertBefore(child, anchor || null);
@@ -95,7 +95,7 @@ const DOMTransitionPropsValidators = {
95
95
  leaveActiveClass: String,
96
96
  leaveToClass: String
97
97
  };
98
- const TransitionPropsValidators = /* @__PURE__ */ (0, _vue_shared.extend)({}, _vue_runtime_core.BaseTransitionPropsValidators, DOMTransitionPropsValidators);
98
+ const TransitionPropsValidators = /*@__PURE__*/ (0, _vue_shared.extend)({}, _vue_runtime_core.BaseTransitionPropsValidators, DOMTransitionPropsValidators);
99
99
  /**
100
100
  * Wrap logic that attaches extra properties to Transition in a function
101
101
  * so that it can be annotated as pure
@@ -109,7 +109,7 @@ const decorate$1 = (t) => {
109
109
  * DOM Transition is a higher-order-component based on the platform-agnostic
110
110
  * base Transition component, with DOM-specific logic.
111
111
  */
112
- const Transition = /* @__PURE__ */ decorate$1((props, { slots }) => (0, _vue_runtime_core.h)(_vue_runtime_core.BaseTransition, resolveTransitionProps(props), slots));
112
+ const Transition = /*@__PURE__*/ decorate$1((props, { slots }) => (0, _vue_runtime_core.h)(_vue_runtime_core.BaseTransition, resolveTransitionProps(props), slots));
113
113
  /**
114
114
  * #3227 Incoming hooks may be merged into arrays when wrapping Transition
115
115
  * with custom HOCs.
@@ -331,14 +331,15 @@ const vShow = {
331
331
  },
332
332
  updated(el, { value, oldValue }, { transition }) {
333
333
  if (!value === !oldValue) return;
334
- if (transition) if (value) {
335
- transition.beforeEnter(el);
336
- setDisplay(el, true);
337
- transition.enter(el);
338
- } else transition.leave(el, () => {
339
- setDisplay(el, false);
340
- });
341
- else setDisplay(el, value);
334
+ if (transition) {
335
+ if (value) {
336
+ transition.beforeEnter(el);
337
+ setDisplay(el, true);
338
+ transition.enter(el);
339
+ } else transition.leave(el, () => {
340
+ setDisplay(el, false);
341
+ });
342
+ } else setDisplay(el, value);
342
343
  },
343
344
  beforeUnmount(el, { value }) {
344
345
  setDisplay(el, value);
@@ -369,11 +370,13 @@ function patchStyle(el, prev, next) {
369
370
  const isCssString = (0, _vue_shared.isString)(next);
370
371
  let hasControlledDisplay = false;
371
372
  if (next && !isCssString) {
372
- if (prev) if (!(0, _vue_shared.isString)(prev)) {
373
- for (const key in prev) if (next[key] == null) setStyle(style, key, "");
374
- } else for (const prevStyle of prev.split(";")) {
375
- const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
376
- if (next[key] == null) setStyle(style, key, "");
373
+ if (prev) {
374
+ if (!(0, _vue_shared.isString)(prev)) {
375
+ for (const key in prev) if (next[key] == null) setStyle(style, key, "");
376
+ } else for (const prevStyle of prev.split(";")) {
377
+ const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
378
+ if (next[key] == null) setStyle(style, key, "");
379
+ }
377
380
  }
378
381
  for (const key in next) {
379
382
  if (key === "display") hasControlledDisplay = true;
@@ -389,7 +392,11 @@ function patchStyle(el, prev, next) {
389
392
  style.cssText = next;
390
393
  hasControlledDisplay = displayRE.test(next);
391
394
  }
392
- } else if (prev) el.removeAttribute("style");
395
+ } else if (prev) {
396
+ const cssVarText = style[CSS_VAR_TEXT];
397
+ if (cssVarText) style.cssText = cssVarText;
398
+ else el.removeAttribute("style");
399
+ }
393
400
  if (vShowOriginalDisplay in el) {
394
401
  el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
395
402
  if (el[vShowHidden]) style.display = "none";
@@ -402,8 +409,10 @@ function setStyle(style, name, rawVal) {
402
409
  else {
403
410
  const val = rawVal == null ? "" : String(rawVal);
404
411
  if (semicolonRE.test(val)) (0, _vue_runtime_core.warn)(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
405
- if (name.startsWith("--")) style.setProperty(name, val);
406
- else {
412
+ if (name.startsWith("--")) {
413
+ if (importantRE.test(val)) style.setProperty(name, val.replace(importantRE, ""), "important");
414
+ else style.setProperty(name, val);
415
+ } else {
407
416
  const prefixed = autoPrefix(style, name);
408
417
  if (importantRE.test(val)) style.setProperty((0, _vue_shared.hyphenate)(prefixed), val.replace(importantRE, ""), "important");
409
418
  else style[prefixed] = val;
@@ -440,9 +449,10 @@ function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
440
449
  //#region packages/runtime-dom/src/modules/attrs.ts
441
450
  const xlinkNS = "http://www.w3.org/1999/xlink";
442
451
  function patchAttr(el, key, value, isSVG, instance, isBoolean = (0, _vue_shared.isSpecialBooleanAttr)(key)) {
443
- if (isSVG && key.startsWith("xlink:")) if (value == null) el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
444
- else el.setAttributeNS(xlinkNS, key, value);
445
- else if (value == null || isBoolean && !(0, _vue_shared.includeBooleanAttr)(value)) el.removeAttribute(key);
452
+ if (isSVG && key.startsWith("xlink:")) {
453
+ if (value == null) el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
454
+ else el.setAttributeNS(xlinkNS, key, value);
455
+ } else if (value == null || isBoolean && !(0, _vue_shared.includeBooleanAttr)(value)) el.removeAttribute(key);
446
456
  else el.setAttribute(key, isBoolean ? "" : (0, _vue_shared.isSymbol)(value) ? String(value) : value);
447
457
  }
448
458
  //#endregion
@@ -515,7 +525,7 @@ function parseEventName(name) {
515
525
  return [name[2] === ":" ? name.slice(3) : (0, _vue_shared.hyphenate)(name.slice(2)), options];
516
526
  }
517
527
  let cachedNow = 0;
518
- const p = /* @__PURE__ */ Promise.resolve();
528
+ const p = /*@__PURE__*/ Promise.resolve();
519
529
  const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
520
530
  function createInvoker(initialValue, instance) {
521
531
  const invoker = (e) => {
@@ -583,7 +593,7 @@ function shouldSetAsPropForVueCE(el, key) {
583
593
  //#endregion
584
594
  //#region packages/runtime-dom/src/apiCustomElement.ts
585
595
  const REMOVAL = {};
586
- /* @__NO_SIDE_EFFECTS__ */
596
+ /*@__NO_SIDE_EFFECTS__*/
587
597
  function defineCustomElement(options, extraOptions, _createApp) {
588
598
  let Comp = (0, _vue_runtime_core.defineComponent)(options, extraOptions);
589
599
  if ((0, _vue_shared.isPlainObject)(Comp)) Comp = (0, _vue_shared.extend)({}, Comp, extraOptions);
@@ -632,12 +642,14 @@ var VueElementBase = class VueElementBase extends BaseClass {
632
642
  this._parent = parent;
633
643
  break;
634
644
  }
635
- if (!this._instance) if (this._resolved) this._mountComponent(this._def);
636
- else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => {
637
- this._pendingResolve = void 0;
638
- this._resolveDef();
639
- });
640
- else this._resolveDef();
645
+ if (!this._instance) {
646
+ if (this._resolved) this._mountComponent(this._def);
647
+ else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => {
648
+ this._pendingResolve = void 0;
649
+ if (this.isConnected) return this._resolveDef();
650
+ });
651
+ else this._resolveDef();
652
+ }
641
653
  }
642
654
  disconnectedCallback() {
643
655
  this._connected = false;
@@ -671,7 +683,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
671
683
  * resolve inner component definition (handle possible async component)
672
684
  */
673
685
  _resolveDef() {
674
- if (this._pendingResolve) return;
686
+ if (this._pendingResolve) return this._pendingResolve;
675
687
  for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name);
676
688
  this._ob = new MutationObserver(this._processMutations.bind(this));
677
689
  this._ob.observe(this, { attributes: true });
@@ -701,6 +713,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
701
713
  this._def = def;
702
714
  resolve(def);
703
715
  });
716
+ return this._pendingResolve;
704
717
  } else resolve(this._def);
705
718
  }
706
719
  _mountComponent(def) {
@@ -739,14 +752,17 @@ var VueElementBase = class VueElementBase extends BaseClass {
739
752
  const { props } = def;
740
753
  const declaredPropKeys = (0, _vue_shared.isArray)(props) ? props : Object.keys(props || {});
741
754
  for (const key of Object.keys(this)) if (key[0] !== "_" && declaredPropKeys.includes(key)) this._setProp(key, this[key]);
742
- for (const key of declaredPropKeys.map(_vue_shared.camelize)) Object.defineProperty(this, key, {
743
- get() {
744
- return this._getProp(key);
745
- },
746
- set(val) {
747
- this._setProp(key, val, true, !this._patching);
748
- }
749
- });
755
+ for (const key of declaredPropKeys.map(_vue_shared.camelize)) {
756
+ if (key in Object.getPrototypeOf(this)) (0, _vue_runtime_core.warn)(`Custom element prop "${key}" conflicts with an existing property on the element and will overwrite it.`);
757
+ Object.defineProperty(this, key, {
758
+ get() {
759
+ return this._getProp(key);
760
+ },
761
+ set(val) {
762
+ this._setProp(key, val, true, !this._patching);
763
+ }
764
+ });
765
+ }
750
766
  }
751
767
  _setAttr(key) {
752
768
  if (key.startsWith("data-v-")) return;
@@ -849,13 +865,11 @@ var VueElementBase = class VueElementBase extends BaseClass {
849
865
  _renderSlots() {
850
866
  const outlets = this._getSlots();
851
867
  const scopeId = this._instance.type.__scopeId;
852
- const slotReplacements = /* @__PURE__ */ new Map();
853
868
  for (let i = 0; i < outlets.length; i++) {
854
869
  const o = outlets[i];
855
870
  const slotName = o.getAttribute("name") || "default";
856
871
  const content = this._slots[slotName];
857
872
  const parent = o.parentNode;
858
- const replacementNodes = [];
859
873
  if (content) for (const n of content) {
860
874
  if (scopeId && n.nodeType === 1) {
861
875
  const id = scopeId + "-s";
@@ -865,20 +879,10 @@ var VueElementBase = class VueElementBase extends BaseClass {
865
879
  while (child = walker.nextNode()) child.setAttribute(id, "");
866
880
  }
867
881
  parent.insertBefore(n, o);
868
- replacementNodes.push(n);
869
- }
870
- else while (o.firstChild) {
871
- const child = o.firstChild;
872
- parent.insertBefore(child, o);
873
- replacementNodes.push(child);
874
882
  }
883
+ else while (o.firstChild) parent.insertBefore(o.firstChild, o);
875
884
  parent.removeChild(o);
876
- slotReplacements.set(o, {
877
- nodes: replacementNodes,
878
- usedFallback: !content
879
- });
880
885
  }
881
- this._updateSlotNodes(slotReplacements);
882
886
  }
883
887
  /**
884
888
  * @internal
@@ -917,7 +921,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
917
921
  * @internal
918
922
  */
919
923
  _hasShadowRoot() {
920
- return this._def.shadowRoot !== false;
924
+ return this._root !== this;
921
925
  }
922
926
  /**
923
927
  * @internal
@@ -962,10 +966,6 @@ var VueElement = class extends VueElementBase {
962
966
  if (this._instance && this._instance.ce) this._instance.ce = void 0;
963
967
  this._app = this._instance = null;
964
968
  }
965
- /**
966
- * Only called when shadowRoot is false
967
- */
968
- _updateSlotNodes(replacements) {}
969
969
  _createVNode() {
970
970
  const baseProps = {};
971
971
  if (!this.shadowRoot) baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
@@ -1031,7 +1031,7 @@ const decorate = (t) => {
1031
1031
  };
1032
1032
  const TransitionGroup = /* @__PURE__ */ decorate({
1033
1033
  name: "TransitionGroup",
1034
- props: /* @__PURE__ */ (0, _vue_shared.extend)({}, TransitionPropsValidators, {
1034
+ props: /*@__PURE__*/ (0, _vue_shared.extend)({}, TransitionPropsValidators, {
1035
1035
  tag: String,
1036
1036
  moveClass: String
1037
1037
  }),
@@ -1162,13 +1162,22 @@ function onCompositionEnd(e) {
1162
1162
  }
1163
1163
  }
1164
1164
  const assignKey = Symbol("_assign");
1165
+ const initialValueKey = Symbol("_initialValue");
1165
1166
  const vModelText = {
1166
1167
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
1168
+ if (el.parentNode) {
1169
+ if (el.type === "text") el[initialValueKey] = el.defaultValue.replace(/[\r\n]/g, "");
1170
+ else if (el.type === "textarea") el[initialValueKey] = el.defaultValue.replace(/\r\n?/g, "\n");
1171
+ }
1167
1172
  el[assignKey] = getModelAssigner(vnode);
1168
1173
  vModelTextInit(el, trim, number || !!(vnode.props && vnode.props.type === "number"), lazy);
1169
1174
  },
1170
- mounted(el, { value }) {
1171
- el.value = value == null ? "" : value;
1175
+ mounted(el, { value, modifiers: { trim, number } }) {
1176
+ const newValue = value == null ? "" : value;
1177
+ const initialValue = el[initialValueKey];
1178
+ delete el[initialValueKey];
1179
+ if (initialValue !== void 0 && (el.type === "text" || el.type === "textarea") && el.value !== initialValue) el[assignKey](castValue(el.value, trim, number));
1180
+ else el.value = newValue;
1172
1181
  },
1173
1182
  beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
1174
1183
  el[assignKey] = getModelAssigner(vnode);
@@ -1303,19 +1312,39 @@ const vModelSelectInit = (el, value, number, set) => {
1303
1312
  el._modelValue = value;
1304
1313
  addEventListener(el, "change", () => {
1305
1314
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? (0, _vue_shared.looseToNumber)(getValue(o)) : getValue(o));
1306
- (set || el[assignKey])(el.multiple ? (0, _vue_shared.isSet)(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]);
1307
- el._assigning = true;
1308
- (0, _vue_runtime_core.nextTick)(() => {
1309
- el._assigning = false;
1310
- });
1315
+ const multiple = el.multiple;
1316
+ const assignedValue = multiple ? (0, _vue_shared.isSet)(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0];
1317
+ const pending = el._pendingValue = [multiple, multiple ? (0, _vue_shared.isArray)(assignedValue) ? selectedVal.slice() : selectedVal : assignedValue];
1318
+ try {
1319
+ (set || el[assignKey])(assignedValue);
1320
+ } finally {
1321
+ (0, _vue_runtime_core.nextTick)(() => {
1322
+ if (el._pendingValue === pending) el._pendingValue = void 0;
1323
+ });
1324
+ }
1311
1325
  });
1312
1326
  };
1327
+ function isSameSelectValue(value, assignedValue, multiple) {
1328
+ if (!multiple) return (0, _vue_shared.looseEqual)(value, assignedValue);
1329
+ if ((0, _vue_shared.isArray)(value)) return (0, _vue_shared.looseEqual)(value, assignedValue);
1330
+ if ((0, _vue_shared.isSet)(value)) {
1331
+ if (value.size !== assignedValue.length) return false;
1332
+ for (const item of assignedValue) if (!value.has(item)) return false;
1333
+ return true;
1334
+ }
1335
+ return false;
1336
+ }
1313
1337
  /**
1314
1338
  * @internal
1315
1339
  */
1316
1340
  const vModelSetSelected = (el, value) => {
1317
1341
  el._modelValue = value;
1318
- if (el._assigning) return;
1342
+ const pending = el._pendingValue;
1343
+ el._pendingValue = void 0;
1344
+ if (pending && pending[0] === el.multiple && isSameSelectValue(value, pending[1], pending[0])) return;
1345
+ setSelected(el, value);
1346
+ };
1347
+ function setSelected(el, value) {
1319
1348
  const isMultiple = el.multiple;
1320
1349
  const isArrayValue = (0, _vue_shared.isArray)(value);
1321
1350
  if (isMultiple && !isArrayValue && !(0, _vue_shared.isSet)(value)) {
@@ -1325,18 +1354,19 @@ const vModelSetSelected = (el, value) => {
1325
1354
  for (let i = 0, l = el.options.length; i < l; i++) {
1326
1355
  const option = el.options[i];
1327
1356
  const optionValue = getValue(option);
1328
- if (isMultiple) if (isArrayValue) {
1329
- const optionType = typeof optionValue;
1330
- if (optionType === "string" || optionType === "number") option.selected = value.some((v) => String(v) === String(optionValue));
1331
- else option.selected = (0, _vue_shared.looseIndexOf)(value, optionValue) > -1;
1332
- } else option.selected = value.has(optionValue);
1333
- else if ((0, _vue_shared.looseEqual)(getValue(option), value)) {
1357
+ if (isMultiple) {
1358
+ if (isArrayValue) {
1359
+ const optionType = typeof optionValue;
1360
+ if (optionType === "string" || optionType === "number") option.selected = value.some((v) => String(v) === String(optionValue));
1361
+ else option.selected = (0, _vue_shared.looseIndexOf)(value, optionValue) > -1;
1362
+ } else option.selected = value.has(optionValue);
1363
+ } else if ((0, _vue_shared.looseEqual)(getValue(option), value)) {
1334
1364
  if (el.selectedIndex !== i) el.selectedIndex = i;
1335
1365
  return;
1336
1366
  }
1337
1367
  }
1338
1368
  if (!isMultiple && el.selectedIndex !== -1) el.selectedIndex = -1;
1339
- };
1369
+ }
1340
1370
  /**
1341
1371
  * @internal retrieve raw value set via :value bindings
1342
1372
  */
@@ -1456,7 +1486,7 @@ const withKeys = (fn, modifiers) => {
1456
1486
  };
1457
1487
  //#endregion
1458
1488
  //#region packages/runtime-dom/src/index.ts
1459
- const rendererOptions = /* @__PURE__ */ (0, _vue_shared.extend)({ patchProp }, nodeOps);
1489
+ const rendererOptions = /*@__PURE__*/ (0, _vue_shared.extend)({ patchProp }, nodeOps);
1460
1490
  let renderer;
1461
1491
  let enabledHydration = false;
1462
1492
  function ensureRenderer() {