@vue/runtime-dom 3.6.0-beta.9 → 3.6.0-rc.10
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.
- package/dist/runtime-dom.cjs.js +147 -98
- package/dist/runtime-dom.cjs.prod.js +136 -90
- package/dist/runtime-dom.d.ts +147 -151
- package/dist/runtime-dom.esm-browser.js +1221 -738
- package/dist/runtime-dom.esm-browser.prod.js +4 -3
- package/dist/runtime-dom.esm-bundler.js +194 -143
- package/dist/runtime-dom.global.js +1221 -738
- package/dist/runtime-dom.global.prod.js +4 -3
- package/package.json +5 -5
package/dist/runtime-dom.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-dom v3.6.0-
|
|
2
|
+
* @vue/runtime-dom v3.6.0-rc.10
|
|
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 =
|
|
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 &&
|
|
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 =
|
|
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 =
|
|
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)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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,15 +370,20 @@ 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)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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;
|
|
380
|
-
|
|
383
|
+
const value = next[key];
|
|
384
|
+
if (value != null) {
|
|
385
|
+
if (!shouldPreserveTextareaResizeStyle(el, key, !(0, _vue_shared.isString)(prev) && prev ? prev[key] : void 0, value)) setStyle(style, key, value);
|
|
386
|
+
} else setStyle(style, key, "");
|
|
381
387
|
}
|
|
382
388
|
} else if (isCssString) {
|
|
383
389
|
if (prev !== next) {
|
|
@@ -386,7 +392,11 @@ function patchStyle(el, prev, next) {
|
|
|
386
392
|
style.cssText = next;
|
|
387
393
|
hasControlledDisplay = displayRE.test(next);
|
|
388
394
|
}
|
|
389
|
-
} else if (prev)
|
|
395
|
+
} else if (prev) {
|
|
396
|
+
const cssVarText = style[CSS_VAR_TEXT];
|
|
397
|
+
if (cssVarText) style.cssText = cssVarText;
|
|
398
|
+
else el.removeAttribute("style");
|
|
399
|
+
}
|
|
390
400
|
if (vShowOriginalDisplay in el) {
|
|
391
401
|
el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
|
|
392
402
|
if (el[vShowHidden]) style.display = "none";
|
|
@@ -399,8 +409,10 @@ function setStyle(style, name, rawVal) {
|
|
|
399
409
|
else {
|
|
400
410
|
const val = rawVal == null ? "" : String(rawVal);
|
|
401
411
|
if (semicolonRE.test(val)) (0, _vue_runtime_core.warn)(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
|
|
402
|
-
if (name.startsWith("--"))
|
|
403
|
-
|
|
412
|
+
if (name.startsWith("--")) {
|
|
413
|
+
if (importantRE.test(val)) style.setProperty(name, val.replace(importantRE, ""), "important");
|
|
414
|
+
else style.setProperty(name, val);
|
|
415
|
+
} else {
|
|
404
416
|
const prefixed = autoPrefix(style, name);
|
|
405
417
|
if (importantRE.test(val)) style.setProperty((0, _vue_shared.hyphenate)(prefixed), val.replace(importantRE, ""), "important");
|
|
406
418
|
else style[prefixed] = val;
|
|
@@ -425,13 +437,22 @@ function autoPrefix(style, rawName) {
|
|
|
425
437
|
}
|
|
426
438
|
return rawName;
|
|
427
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Browsers update textarea width/height directly during native resize.
|
|
442
|
+
* Only special-case this common textarea path for now; other resize scenarios
|
|
443
|
+
* still follow normal vnode style patching.
|
|
444
|
+
*/
|
|
445
|
+
function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
|
|
446
|
+
return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && (0, _vue_shared.isString)(next) && prev === next;
|
|
447
|
+
}
|
|
428
448
|
//#endregion
|
|
429
449
|
//#region packages/runtime-dom/src/modules/attrs.ts
|
|
430
450
|
const xlinkNS = "http://www.w3.org/1999/xlink";
|
|
431
451
|
function patchAttr(el, key, value, isSVG, instance, isBoolean = (0, _vue_shared.isSpecialBooleanAttr)(key)) {
|
|
432
|
-
if (isSVG && key.startsWith("xlink:"))
|
|
433
|
-
|
|
434
|
-
|
|
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);
|
|
435
456
|
else el.setAttribute(key, isBoolean ? "" : (0, _vue_shared.isSymbol)(value) ? String(value) : value);
|
|
436
457
|
}
|
|
437
458
|
//#endregion
|
|
@@ -483,7 +504,7 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
|
|
483
504
|
const existingInvoker = invokers[rawName];
|
|
484
505
|
if (nextValue && existingInvoker) existingInvoker.value = sanitizeEventValue(nextValue, rawName);
|
|
485
506
|
else {
|
|
486
|
-
const [name, options] =
|
|
507
|
+
const [name, options] = parseEventName(rawName);
|
|
487
508
|
if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(sanitizeEventValue(nextValue, rawName), instance), options);
|
|
488
509
|
else if (existingInvoker) {
|
|
489
510
|
removeEventListener(el, name, existingInvoker, options);
|
|
@@ -491,27 +512,40 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
|
|
491
512
|
}
|
|
492
513
|
}
|
|
493
514
|
}
|
|
494
|
-
const optionsModifierRE = /(
|
|
495
|
-
|
|
515
|
+
const optionsModifierRE = /(Once|Passive|Capture)$/;
|
|
516
|
+
const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
|
|
517
|
+
function parseEventName(name) {
|
|
496
518
|
let options;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
options[m[0].toLowerCase()] = true;
|
|
503
|
-
}
|
|
519
|
+
let m;
|
|
520
|
+
while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
|
|
521
|
+
if (!options) options = {};
|
|
522
|
+
name = name.slice(0, name.length - m[1].length);
|
|
523
|
+
options[m[1].toLowerCase()] = true;
|
|
504
524
|
}
|
|
505
525
|
return [name[2] === ":" ? name.slice(3) : (0, _vue_shared.hyphenate)(name.slice(2)), options];
|
|
506
526
|
}
|
|
507
527
|
let cachedNow = 0;
|
|
508
|
-
const p =
|
|
528
|
+
const p = /*@__PURE__*/ Promise.resolve();
|
|
509
529
|
const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
|
510
530
|
function createInvoker(initialValue, instance) {
|
|
511
531
|
const invoker = (e) => {
|
|
512
532
|
if (!e._vts) e._vts = Date.now();
|
|
513
533
|
else if (e._vts <= invoker.attached) return;
|
|
514
|
-
|
|
534
|
+
const value = invoker.value;
|
|
535
|
+
if ((0, _vue_shared.isArray)(value)) {
|
|
536
|
+
const originalStop = e.stopImmediatePropagation;
|
|
537
|
+
e.stopImmediatePropagation = () => {
|
|
538
|
+
originalStop.call(e);
|
|
539
|
+
e._stopped = true;
|
|
540
|
+
};
|
|
541
|
+
const handlers = value.slice();
|
|
542
|
+
const args = [e];
|
|
543
|
+
for (let i = 0; i < handlers.length; i++) {
|
|
544
|
+
if (e._stopped) break;
|
|
545
|
+
const handler = handlers[i];
|
|
546
|
+
if (handler) (0, _vue_runtime_core.callWithAsyncErrorHandling)(handler, instance, 5, args);
|
|
547
|
+
}
|
|
548
|
+
} else (0, _vue_runtime_core.callWithAsyncErrorHandling)(value, instance, 5, [e]);
|
|
515
549
|
};
|
|
516
550
|
invoker.value = initialValue;
|
|
517
551
|
invoker.attached = getNow();
|
|
@@ -522,16 +556,6 @@ function sanitizeEventValue(value, propName) {
|
|
|
522
556
|
(0, _vue_runtime_core.warn)(`Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?\nExpected function or array of functions, received type ${typeof value}.`);
|
|
523
557
|
return _vue_shared.NOOP;
|
|
524
558
|
}
|
|
525
|
-
function patchStopImmediatePropagation(e, value) {
|
|
526
|
-
if ((0, _vue_shared.isArray)(value)) {
|
|
527
|
-
const originalStop = e.stopImmediatePropagation;
|
|
528
|
-
e.stopImmediatePropagation = () => {
|
|
529
|
-
originalStop.call(e);
|
|
530
|
-
e._stopped = true;
|
|
531
|
-
};
|
|
532
|
-
return value.map((fn) => (e) => !e._stopped && fn && fn(e));
|
|
533
|
-
} else return value;
|
|
534
|
-
}
|
|
535
559
|
//#endregion
|
|
536
560
|
//#region packages/runtime-dom/src/patchProp.ts
|
|
537
561
|
const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
|
@@ -569,7 +593,7 @@ function shouldSetAsPropForVueCE(el, key) {
|
|
|
569
593
|
//#endregion
|
|
570
594
|
//#region packages/runtime-dom/src/apiCustomElement.ts
|
|
571
595
|
const REMOVAL = {};
|
|
572
|
-
|
|
596
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
573
597
|
function defineCustomElement(options, extraOptions, _createApp) {
|
|
574
598
|
let Comp = (0, _vue_runtime_core.defineComponent)(options, extraOptions);
|
|
575
599
|
if ((0, _vue_shared.isPlainObject)(Comp)) Comp = (0, _vue_shared.extend)({}, Comp, extraOptions);
|
|
@@ -618,12 +642,14 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
618
642
|
this._parent = parent;
|
|
619
643
|
break;
|
|
620
644
|
}
|
|
621
|
-
if (!this._instance)
|
|
622
|
-
|
|
623
|
-
this._pendingResolve =
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
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
|
+
}
|
|
627
653
|
}
|
|
628
654
|
disconnectedCallback() {
|
|
629
655
|
this._connected = false;
|
|
@@ -657,7 +683,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
657
683
|
* resolve inner component definition (handle possible async component)
|
|
658
684
|
*/
|
|
659
685
|
_resolveDef() {
|
|
660
|
-
if (this._pendingResolve) return;
|
|
686
|
+
if (this._pendingResolve) return this._pendingResolve;
|
|
661
687
|
for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name);
|
|
662
688
|
this._ob = new MutationObserver(this._processMutations.bind(this));
|
|
663
689
|
this._ob.observe(this, { attributes: true });
|
|
@@ -687,6 +713,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
687
713
|
this._def = def;
|
|
688
714
|
resolve(def);
|
|
689
715
|
});
|
|
716
|
+
return this._pendingResolve;
|
|
690
717
|
} else resolve(this._def);
|
|
691
718
|
}
|
|
692
719
|
_mountComponent(def) {
|
|
@@ -725,14 +752,17 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
725
752
|
const { props } = def;
|
|
726
753
|
const declaredPropKeys = (0, _vue_shared.isArray)(props) ? props : Object.keys(props || {});
|
|
727
754
|
for (const key of Object.keys(this)) if (key[0] !== "_" && declaredPropKeys.includes(key)) this._setProp(key, this[key]);
|
|
728
|
-
for (const key of declaredPropKeys.map(_vue_shared.camelize))
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
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
|
+
}
|
|
736
766
|
}
|
|
737
767
|
_setAttr(key) {
|
|
738
768
|
if (key.startsWith("data-v-")) return;
|
|
@@ -835,13 +865,11 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
835
865
|
_renderSlots() {
|
|
836
866
|
const outlets = this._getSlots();
|
|
837
867
|
const scopeId = this._instance.type.__scopeId;
|
|
838
|
-
const slotReplacements = /* @__PURE__ */ new Map();
|
|
839
868
|
for (let i = 0; i < outlets.length; i++) {
|
|
840
869
|
const o = outlets[i];
|
|
841
870
|
const slotName = o.getAttribute("name") || "default";
|
|
842
871
|
const content = this._slots[slotName];
|
|
843
872
|
const parent = o.parentNode;
|
|
844
|
-
const replacementNodes = [];
|
|
845
873
|
if (content) for (const n of content) {
|
|
846
874
|
if (scopeId && n.nodeType === 1) {
|
|
847
875
|
const id = scopeId + "-s";
|
|
@@ -851,17 +879,10 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
851
879
|
while (child = walker.nextNode()) child.setAttribute(id, "");
|
|
852
880
|
}
|
|
853
881
|
parent.insertBefore(n, o);
|
|
854
|
-
replacementNodes.push(n);
|
|
855
|
-
}
|
|
856
|
-
else while (o.firstChild) {
|
|
857
|
-
const child = o.firstChild;
|
|
858
|
-
parent.insertBefore(child, o);
|
|
859
|
-
replacementNodes.push(child);
|
|
860
882
|
}
|
|
883
|
+
else while (o.firstChild) parent.insertBefore(o.firstChild, o);
|
|
861
884
|
parent.removeChild(o);
|
|
862
|
-
slotReplacements.set(o, replacementNodes);
|
|
863
885
|
}
|
|
864
|
-
this._updateSlotNodes(slotReplacements);
|
|
865
886
|
}
|
|
866
887
|
/**
|
|
867
888
|
* @internal
|
|
@@ -900,7 +921,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
900
921
|
* @internal
|
|
901
922
|
*/
|
|
902
923
|
_hasShadowRoot() {
|
|
903
|
-
return this.
|
|
924
|
+
return this._root !== this;
|
|
904
925
|
}
|
|
905
926
|
/**
|
|
906
927
|
* @internal
|
|
@@ -945,10 +966,6 @@ var VueElement = class extends VueElementBase {
|
|
|
945
966
|
if (this._instance && this._instance.ce) this._instance.ce = void 0;
|
|
946
967
|
this._app = this._instance = null;
|
|
947
968
|
}
|
|
948
|
-
/**
|
|
949
|
-
* Only called when shadowRoot is false
|
|
950
|
-
*/
|
|
951
|
-
_updateSlotNodes(replacements) {}
|
|
952
969
|
_createVNode() {
|
|
953
970
|
const baseProps = {};
|
|
954
971
|
if (!this.shadowRoot) baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
|
|
@@ -1014,7 +1031,7 @@ const decorate = (t) => {
|
|
|
1014
1031
|
};
|
|
1015
1032
|
const TransitionGroup = /* @__PURE__ */ decorate({
|
|
1016
1033
|
name: "TransitionGroup",
|
|
1017
|
-
props:
|
|
1034
|
+
props: /*@__PURE__*/ (0, _vue_shared.extend)({}, TransitionPropsValidators, {
|
|
1018
1035
|
tag: String,
|
|
1019
1036
|
moveClass: String
|
|
1020
1037
|
}),
|
|
@@ -1047,7 +1064,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
|
|
|
1047
1064
|
prevChildren = [];
|
|
1048
1065
|
if (children) for (let i = 0; i < children.length; i++) {
|
|
1049
1066
|
const child = children[i];
|
|
1050
|
-
if (child.el && child.el instanceof Element) {
|
|
1067
|
+
if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
|
|
1051
1068
|
prevChildren.push(child);
|
|
1052
1069
|
(0, _vue_runtime_core.setTransitionHooks)(child, (0, _vue_runtime_core.resolveTransitionHooks)(child, cssTransitionProps, state, instance));
|
|
1053
1070
|
positionMap.set(child, getPosition(child.el));
|
|
@@ -1145,13 +1162,22 @@ function onCompositionEnd(e) {
|
|
|
1145
1162
|
}
|
|
1146
1163
|
}
|
|
1147
1164
|
const assignKey = Symbol("_assign");
|
|
1165
|
+
const initialValueKey = Symbol("_initialValue");
|
|
1148
1166
|
const vModelText = {
|
|
1149
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
|
+
}
|
|
1150
1172
|
el[assignKey] = getModelAssigner(vnode);
|
|
1151
1173
|
vModelTextInit(el, trim, number || !!(vnode.props && vnode.props.type === "number"), lazy);
|
|
1152
1174
|
},
|
|
1153
|
-
mounted(el, { value }) {
|
|
1154
|
-
|
|
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;
|
|
1155
1181
|
},
|
|
1156
1182
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1157
1183
|
el[assignKey] = getModelAssigner(vnode);
|
|
@@ -1271,7 +1297,8 @@ const vModelSelect = {
|
|
|
1271
1297
|
mounted(el, { value }) {
|
|
1272
1298
|
vModelSetSelected(el, value);
|
|
1273
1299
|
},
|
|
1274
|
-
beforeUpdate(el,
|
|
1300
|
+
beforeUpdate(el, { value }, vnode) {
|
|
1301
|
+
el._modelValue = value;
|
|
1275
1302
|
el[assignKey] = getModelAssigner(vnode);
|
|
1276
1303
|
},
|
|
1277
1304
|
updated(el, { value }) {
|
|
@@ -1282,21 +1309,42 @@ const vModelSelect = {
|
|
|
1282
1309
|
* @internal
|
|
1283
1310
|
*/
|
|
1284
1311
|
const vModelSelectInit = (el, value, number, set) => {
|
|
1285
|
-
|
|
1312
|
+
el._modelValue = value;
|
|
1286
1313
|
addEventListener(el, "change", () => {
|
|
1287
1314
|
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? (0, _vue_shared.looseToNumber)(getValue(o)) : getValue(o));
|
|
1288
|
-
|
|
1289
|
-
el.
|
|
1290
|
-
(0,
|
|
1291
|
-
|
|
1292
|
-
|
|
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
|
+
}
|
|
1293
1325
|
});
|
|
1294
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
|
+
}
|
|
1295
1337
|
/**
|
|
1296
1338
|
* @internal
|
|
1297
1339
|
*/
|
|
1298
1340
|
const vModelSetSelected = (el, value) => {
|
|
1299
|
-
|
|
1341
|
+
el._modelValue = value;
|
|
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) {
|
|
1300
1348
|
const isMultiple = el.multiple;
|
|
1301
1349
|
const isArrayValue = (0, _vue_shared.isArray)(value);
|
|
1302
1350
|
if (isMultiple && !isArrayValue && !(0, _vue_shared.isSet)(value)) {
|
|
@@ -1306,18 +1354,19 @@ const vModelSetSelected = (el, value) => {
|
|
|
1306
1354
|
for (let i = 0, l = el.options.length; i < l; i++) {
|
|
1307
1355
|
const option = el.options[i];
|
|
1308
1356
|
const optionValue = getValue(option);
|
|
1309
|
-
if (isMultiple)
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
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)) {
|
|
1315
1364
|
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
1316
1365
|
return;
|
|
1317
1366
|
}
|
|
1318
1367
|
}
|
|
1319
1368
|
if (!isMultiple && el.selectedIndex !== -1) el.selectedIndex = -1;
|
|
1320
|
-
}
|
|
1369
|
+
}
|
|
1321
1370
|
/**
|
|
1322
1371
|
* @internal retrieve raw value set via :value bindings
|
|
1323
1372
|
*/
|
|
@@ -1437,7 +1486,7 @@ const withKeys = (fn, modifiers) => {
|
|
|
1437
1486
|
};
|
|
1438
1487
|
//#endregion
|
|
1439
1488
|
//#region packages/runtime-dom/src/index.ts
|
|
1440
|
-
const rendererOptions =
|
|
1489
|
+
const rendererOptions = /*@__PURE__*/ (0, _vue_shared.extend)({ patchProp }, nodeOps);
|
|
1441
1490
|
let renderer;
|
|
1442
1491
|
let enabledHydration = false;
|
|
1443
1492
|
function ensureRenderer() {
|