@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
|
@@ -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,13 +13,13 @@ 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
|
const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
|
|
19
19
|
const svgNS = "http://www.w3.org/2000/svg";
|
|
20
20
|
const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
|
21
21
|
const doc = typeof document !== "undefined" ? document : null;
|
|
22
|
-
const templateContainer = doc &&
|
|
22
|
+
const templateContainer = doc && /*@__PURE__*/ doc.createElement("template");
|
|
23
23
|
const nodeOps = {
|
|
24
24
|
insert: (child, parent, anchor) => {
|
|
25
25
|
parent.insertBefore(child, anchor || null);
|
|
@@ -93,7 +93,7 @@ const DOMTransitionPropsValidators = {
|
|
|
93
93
|
leaveActiveClass: String,
|
|
94
94
|
leaveToClass: String
|
|
95
95
|
};
|
|
96
|
-
const TransitionPropsValidators =
|
|
96
|
+
const TransitionPropsValidators = /*@__PURE__*/ (0, _vue_shared.extend)({}, _vue_runtime_core.BaseTransitionPropsValidators, DOMTransitionPropsValidators);
|
|
97
97
|
/**
|
|
98
98
|
* Wrap logic that attaches extra properties to Transition in a function
|
|
99
99
|
* so that it can be annotated as pure
|
|
@@ -107,7 +107,7 @@ const decorate$1 = (t) => {
|
|
|
107
107
|
* DOM Transition is a higher-order-component based on the platform-agnostic
|
|
108
108
|
* base Transition component, with DOM-specific logic.
|
|
109
109
|
*/
|
|
110
|
-
const Transition =
|
|
110
|
+
const Transition = /*@__PURE__*/ decorate$1((props, { slots }) => (0, _vue_runtime_core.h)(_vue_runtime_core.BaseTransition, resolveTransitionProps(props), slots));
|
|
111
111
|
/**
|
|
112
112
|
* #3227 Incoming hooks may be merged into arrays when wrapping Transition
|
|
113
113
|
* with custom HOCs.
|
|
@@ -327,14 +327,15 @@ const vShow = {
|
|
|
327
327
|
},
|
|
328
328
|
updated(el, { value, oldValue }, { transition }) {
|
|
329
329
|
if (!value === !oldValue) return;
|
|
330
|
-
if (transition)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
330
|
+
if (transition) {
|
|
331
|
+
if (value) {
|
|
332
|
+
transition.beforeEnter(el);
|
|
333
|
+
setDisplay(el, true);
|
|
334
|
+
transition.enter(el);
|
|
335
|
+
} else transition.leave(el, () => {
|
|
336
|
+
setDisplay(el, false);
|
|
337
|
+
});
|
|
338
|
+
} else setDisplay(el, value);
|
|
338
339
|
},
|
|
339
340
|
beforeUnmount(el, { value }) {
|
|
340
341
|
setDisplay(el, value);
|
|
@@ -365,15 +366,20 @@ function patchStyle(el, prev, next) {
|
|
|
365
366
|
const isCssString = (0, _vue_shared.isString)(next);
|
|
366
367
|
let hasControlledDisplay = false;
|
|
367
368
|
if (next && !isCssString) {
|
|
368
|
-
if (prev)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
369
|
+
if (prev) {
|
|
370
|
+
if (!(0, _vue_shared.isString)(prev)) {
|
|
371
|
+
for (const key in prev) if (next[key] == null) setStyle(style, key, "");
|
|
372
|
+
} else for (const prevStyle of prev.split(";")) {
|
|
373
|
+
const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
|
|
374
|
+
if (next[key] == null) setStyle(style, key, "");
|
|
375
|
+
}
|
|
373
376
|
}
|
|
374
377
|
for (const key in next) {
|
|
375
378
|
if (key === "display") hasControlledDisplay = true;
|
|
376
|
-
|
|
379
|
+
const value = next[key];
|
|
380
|
+
if (value != null) {
|
|
381
|
+
if (!shouldPreserveTextareaResizeStyle(el, key, !(0, _vue_shared.isString)(prev) && prev ? prev[key] : void 0, value)) setStyle(style, key, value);
|
|
382
|
+
} else setStyle(style, key, "");
|
|
377
383
|
}
|
|
378
384
|
} else if (isCssString) {
|
|
379
385
|
if (prev !== next) {
|
|
@@ -382,7 +388,11 @@ function patchStyle(el, prev, next) {
|
|
|
382
388
|
style.cssText = next;
|
|
383
389
|
hasControlledDisplay = displayRE.test(next);
|
|
384
390
|
}
|
|
385
|
-
} else if (prev)
|
|
391
|
+
} else if (prev) {
|
|
392
|
+
const cssVarText = style[CSS_VAR_TEXT];
|
|
393
|
+
if (cssVarText) style.cssText = cssVarText;
|
|
394
|
+
else el.removeAttribute("style");
|
|
395
|
+
}
|
|
386
396
|
if (vShowOriginalDisplay in el) {
|
|
387
397
|
el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
|
|
388
398
|
if (el[vShowHidden]) style.display = "none";
|
|
@@ -393,8 +403,10 @@ function setStyle(style, name, rawVal) {
|
|
|
393
403
|
if ((0, _vue_shared.isArray)(rawVal)) rawVal.forEach((v) => setStyle(style, name, v));
|
|
394
404
|
else {
|
|
395
405
|
const val = rawVal == null ? "" : String(rawVal);
|
|
396
|
-
if (name.startsWith("--"))
|
|
397
|
-
|
|
406
|
+
if (name.startsWith("--")) {
|
|
407
|
+
if (importantRE.test(val)) style.setProperty(name, val.replace(importantRE, ""), "important");
|
|
408
|
+
else style.setProperty(name, val);
|
|
409
|
+
} else {
|
|
398
410
|
const prefixed = autoPrefix(style, name);
|
|
399
411
|
if (importantRE.test(val)) style.setProperty((0, _vue_shared.hyphenate)(prefixed), val.replace(importantRE, ""), "important");
|
|
400
412
|
else style[prefixed] = val;
|
|
@@ -419,13 +431,22 @@ function autoPrefix(style, rawName) {
|
|
|
419
431
|
}
|
|
420
432
|
return rawName;
|
|
421
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Browsers update textarea width/height directly during native resize.
|
|
436
|
+
* Only special-case this common textarea path for now; other resize scenarios
|
|
437
|
+
* still follow normal vnode style patching.
|
|
438
|
+
*/
|
|
439
|
+
function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
|
|
440
|
+
return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && (0, _vue_shared.isString)(next) && prev === next;
|
|
441
|
+
}
|
|
422
442
|
//#endregion
|
|
423
443
|
//#region packages/runtime-dom/src/modules/attrs.ts
|
|
424
444
|
const xlinkNS = "http://www.w3.org/1999/xlink";
|
|
425
445
|
function patchAttr(el, key, value, isSVG, instance, isBoolean = (0, _vue_shared.isSpecialBooleanAttr)(key)) {
|
|
426
|
-
if (isSVG && key.startsWith("xlink:"))
|
|
427
|
-
|
|
428
|
-
|
|
446
|
+
if (isSVG && key.startsWith("xlink:")) {
|
|
447
|
+
if (value == null) el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
448
|
+
else el.setAttributeNS(xlinkNS, key, value);
|
|
449
|
+
} else if (value == null || isBoolean && !(0, _vue_shared.includeBooleanAttr)(value)) el.removeAttribute(key);
|
|
429
450
|
else el.setAttribute(key, isBoolean ? "" : (0, _vue_shared.isSymbol)(value) ? String(value) : value);
|
|
430
451
|
}
|
|
431
452
|
//#endregion
|
|
@@ -475,7 +496,7 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
|
|
475
496
|
const existingInvoker = invokers[rawName];
|
|
476
497
|
if (nextValue && existingInvoker) existingInvoker.value = nextValue;
|
|
477
498
|
else {
|
|
478
|
-
const [name, options] =
|
|
499
|
+
const [name, options] = parseEventName(rawName);
|
|
479
500
|
if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(nextValue, instance), options);
|
|
480
501
|
else if (existingInvoker) {
|
|
481
502
|
removeEventListener(el, name, existingInvoker, options);
|
|
@@ -483,42 +504,45 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
|
|
483
504
|
}
|
|
484
505
|
}
|
|
485
506
|
}
|
|
486
|
-
const optionsModifierRE = /(
|
|
487
|
-
|
|
507
|
+
const optionsModifierRE = /(Once|Passive|Capture)$/;
|
|
508
|
+
const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
|
|
509
|
+
function parseEventName(name) {
|
|
488
510
|
let options;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
options[m[0].toLowerCase()] = true;
|
|
495
|
-
}
|
|
511
|
+
let m;
|
|
512
|
+
while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
|
|
513
|
+
if (!options) options = {};
|
|
514
|
+
name = name.slice(0, name.length - m[1].length);
|
|
515
|
+
options[m[1].toLowerCase()] = true;
|
|
496
516
|
}
|
|
497
517
|
return [name[2] === ":" ? name.slice(3) : (0, _vue_shared.hyphenate)(name.slice(2)), options];
|
|
498
518
|
}
|
|
499
519
|
let cachedNow = 0;
|
|
500
|
-
const p =
|
|
520
|
+
const p = /*@__PURE__*/ Promise.resolve();
|
|
501
521
|
const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
|
502
522
|
function createInvoker(initialValue, instance) {
|
|
503
523
|
const invoker = (e) => {
|
|
504
524
|
if (!e._vts) e._vts = Date.now();
|
|
505
525
|
else if (e._vts <= invoker.attached) return;
|
|
506
|
-
|
|
526
|
+
const value = invoker.value;
|
|
527
|
+
if ((0, _vue_shared.isArray)(value)) {
|
|
528
|
+
const originalStop = e.stopImmediatePropagation;
|
|
529
|
+
e.stopImmediatePropagation = () => {
|
|
530
|
+
originalStop.call(e);
|
|
531
|
+
e._stopped = true;
|
|
532
|
+
};
|
|
533
|
+
const handlers = value.slice();
|
|
534
|
+
const args = [e];
|
|
535
|
+
for (let i = 0; i < handlers.length; i++) {
|
|
536
|
+
if (e._stopped) break;
|
|
537
|
+
const handler = handlers[i];
|
|
538
|
+
if (handler) (0, _vue_runtime_core.callWithAsyncErrorHandling)(handler, instance, 5, args);
|
|
539
|
+
}
|
|
540
|
+
} else (0, _vue_runtime_core.callWithAsyncErrorHandling)(value, instance, 5, [e]);
|
|
507
541
|
};
|
|
508
542
|
invoker.value = initialValue;
|
|
509
543
|
invoker.attached = getNow();
|
|
510
544
|
return invoker;
|
|
511
545
|
}
|
|
512
|
-
function patchStopImmediatePropagation(e, value) {
|
|
513
|
-
if ((0, _vue_shared.isArray)(value)) {
|
|
514
|
-
const originalStop = e.stopImmediatePropagation;
|
|
515
|
-
e.stopImmediatePropagation = () => {
|
|
516
|
-
originalStop.call(e);
|
|
517
|
-
e._stopped = true;
|
|
518
|
-
};
|
|
519
|
-
return value.map((fn) => (e) => !e._stopped && fn && fn(e));
|
|
520
|
-
} else return value;
|
|
521
|
-
}
|
|
522
546
|
//#endregion
|
|
523
547
|
//#region packages/runtime-dom/src/patchProp.ts
|
|
524
548
|
const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
|
@@ -556,7 +580,7 @@ function shouldSetAsPropForVueCE(el, key) {
|
|
|
556
580
|
//#endregion
|
|
557
581
|
//#region packages/runtime-dom/src/apiCustomElement.ts
|
|
558
582
|
const REMOVAL = {};
|
|
559
|
-
|
|
583
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
560
584
|
function defineCustomElement(options, extraOptions, _createApp) {
|
|
561
585
|
let Comp = (0, _vue_runtime_core.defineComponent)(options, extraOptions);
|
|
562
586
|
if ((0, _vue_shared.isPlainObject)(Comp)) Comp = (0, _vue_shared.extend)({}, Comp, extraOptions);
|
|
@@ -605,12 +629,14 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
605
629
|
this._parent = parent;
|
|
606
630
|
break;
|
|
607
631
|
}
|
|
608
|
-
if (!this._instance)
|
|
609
|
-
|
|
610
|
-
this._pendingResolve =
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
632
|
+
if (!this._instance) {
|
|
633
|
+
if (this._resolved) this._mountComponent(this._def);
|
|
634
|
+
else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => {
|
|
635
|
+
this._pendingResolve = void 0;
|
|
636
|
+
if (this.isConnected) return this._resolveDef();
|
|
637
|
+
});
|
|
638
|
+
else this._resolveDef();
|
|
639
|
+
}
|
|
614
640
|
}
|
|
615
641
|
disconnectedCallback() {
|
|
616
642
|
this._connected = false;
|
|
@@ -644,7 +670,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
644
670
|
* resolve inner component definition (handle possible async component)
|
|
645
671
|
*/
|
|
646
672
|
_resolveDef() {
|
|
647
|
-
if (this._pendingResolve) return;
|
|
673
|
+
if (this._pendingResolve) return this._pendingResolve;
|
|
648
674
|
for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name);
|
|
649
675
|
this._ob = new MutationObserver(this._processMutations.bind(this));
|
|
650
676
|
this._ob.observe(this, { attributes: true });
|
|
@@ -673,6 +699,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
673
699
|
this._def = def;
|
|
674
700
|
resolve(def);
|
|
675
701
|
});
|
|
702
|
+
return this._pendingResolve;
|
|
676
703
|
} else resolve(this._def);
|
|
677
704
|
}
|
|
678
705
|
_mountComponent(def) {
|
|
@@ -802,13 +829,11 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
802
829
|
_renderSlots() {
|
|
803
830
|
const outlets = this._getSlots();
|
|
804
831
|
const scopeId = this._instance.type.__scopeId;
|
|
805
|
-
const slotReplacements = /* @__PURE__ */ new Map();
|
|
806
832
|
for (let i = 0; i < outlets.length; i++) {
|
|
807
833
|
const o = outlets[i];
|
|
808
834
|
const slotName = o.getAttribute("name") || "default";
|
|
809
835
|
const content = this._slots[slotName];
|
|
810
836
|
const parent = o.parentNode;
|
|
811
|
-
const replacementNodes = [];
|
|
812
837
|
if (content) for (const n of content) {
|
|
813
838
|
if (scopeId && n.nodeType === 1) {
|
|
814
839
|
const id = scopeId + "-s";
|
|
@@ -818,17 +843,10 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
818
843
|
while (child = walker.nextNode()) child.setAttribute(id, "");
|
|
819
844
|
}
|
|
820
845
|
parent.insertBefore(n, o);
|
|
821
|
-
replacementNodes.push(n);
|
|
822
|
-
}
|
|
823
|
-
else while (o.firstChild) {
|
|
824
|
-
const child = o.firstChild;
|
|
825
|
-
parent.insertBefore(child, o);
|
|
826
|
-
replacementNodes.push(child);
|
|
827
846
|
}
|
|
847
|
+
else while (o.firstChild) parent.insertBefore(o.firstChild, o);
|
|
828
848
|
parent.removeChild(o);
|
|
829
|
-
slotReplacements.set(o, replacementNodes);
|
|
830
849
|
}
|
|
831
|
-
this._updateSlotNodes(slotReplacements);
|
|
832
850
|
}
|
|
833
851
|
/**
|
|
834
852
|
* @internal
|
|
@@ -867,7 +885,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
|
|
|
867
885
|
* @internal
|
|
868
886
|
*/
|
|
869
887
|
_hasShadowRoot() {
|
|
870
|
-
return this.
|
|
888
|
+
return this._root !== this;
|
|
871
889
|
}
|
|
872
890
|
/**
|
|
873
891
|
* @internal
|
|
@@ -900,10 +918,6 @@ var VueElement = class extends VueElementBase {
|
|
|
900
918
|
if (this._instance && this._instance.ce) this._instance.ce = void 0;
|
|
901
919
|
this._app = this._instance = null;
|
|
902
920
|
}
|
|
903
|
-
/**
|
|
904
|
-
* Only called when shadowRoot is false
|
|
905
|
-
*/
|
|
906
|
-
_updateSlotNodes(replacements) {}
|
|
907
921
|
_createVNode() {
|
|
908
922
|
const baseProps = {};
|
|
909
923
|
if (!this.shadowRoot) baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
|
|
@@ -958,7 +972,7 @@ const decorate = (t) => {
|
|
|
958
972
|
};
|
|
959
973
|
const TransitionGroup = /* @__PURE__ */ decorate({
|
|
960
974
|
name: "TransitionGroup",
|
|
961
|
-
props:
|
|
975
|
+
props: /*@__PURE__*/ (0, _vue_shared.extend)({}, TransitionPropsValidators, {
|
|
962
976
|
tag: String,
|
|
963
977
|
moveClass: String
|
|
964
978
|
}),
|
|
@@ -991,7 +1005,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
|
|
|
991
1005
|
prevChildren = [];
|
|
992
1006
|
if (children) for (let i = 0; i < children.length; i++) {
|
|
993
1007
|
const child = children[i];
|
|
994
|
-
if (child.el && child.el instanceof Element) {
|
|
1008
|
+
if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
|
|
995
1009
|
prevChildren.push(child);
|
|
996
1010
|
(0, _vue_runtime_core.setTransitionHooks)(child, (0, _vue_runtime_core.resolveTransitionHooks)(child, cssTransitionProps, state, instance));
|
|
997
1011
|
positionMap.set(child, getPosition(child.el));
|
|
@@ -1088,13 +1102,22 @@ function onCompositionEnd(e) {
|
|
|
1088
1102
|
}
|
|
1089
1103
|
}
|
|
1090
1104
|
const assignKey = Symbol("_assign");
|
|
1105
|
+
const initialValueKey = Symbol("_initialValue");
|
|
1091
1106
|
const vModelText = {
|
|
1092
1107
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1108
|
+
if (el.parentNode) {
|
|
1109
|
+
if (el.type === "text") el[initialValueKey] = el.defaultValue.replace(/[\r\n]/g, "");
|
|
1110
|
+
else if (el.type === "textarea") el[initialValueKey] = el.defaultValue.replace(/\r\n?/g, "\n");
|
|
1111
|
+
}
|
|
1093
1112
|
el[assignKey] = getModelAssigner(vnode);
|
|
1094
1113
|
vModelTextInit(el, trim, number || !!(vnode.props && vnode.props.type === "number"), lazy);
|
|
1095
1114
|
},
|
|
1096
|
-
mounted(el, { value }) {
|
|
1097
|
-
|
|
1115
|
+
mounted(el, { value, modifiers: { trim, number } }) {
|
|
1116
|
+
const newValue = value == null ? "" : value;
|
|
1117
|
+
const initialValue = el[initialValueKey];
|
|
1118
|
+
delete el[initialValueKey];
|
|
1119
|
+
if (initialValue !== void 0 && (el.type === "text" || el.type === "textarea") && el.value !== initialValue) el[assignKey](castValue(el.value, trim, number));
|
|
1120
|
+
else el.value = newValue;
|
|
1098
1121
|
},
|
|
1099
1122
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1100
1123
|
el[assignKey] = getModelAssigner(vnode);
|
|
@@ -1214,7 +1237,8 @@ const vModelSelect = {
|
|
|
1214
1237
|
mounted(el, { value }) {
|
|
1215
1238
|
vModelSetSelected(el, value);
|
|
1216
1239
|
},
|
|
1217
|
-
beforeUpdate(el,
|
|
1240
|
+
beforeUpdate(el, { value }, vnode) {
|
|
1241
|
+
el._modelValue = value;
|
|
1218
1242
|
el[assignKey] = getModelAssigner(vnode);
|
|
1219
1243
|
},
|
|
1220
1244
|
updated(el, { value }) {
|
|
@@ -1225,39 +1249,61 @@ const vModelSelect = {
|
|
|
1225
1249
|
* @internal
|
|
1226
1250
|
*/
|
|
1227
1251
|
const vModelSelectInit = (el, value, number, set) => {
|
|
1228
|
-
|
|
1252
|
+
el._modelValue = value;
|
|
1229
1253
|
addEventListener(el, "change", () => {
|
|
1230
1254
|
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? (0, _vue_shared.looseToNumber)(getValue(o)) : getValue(o));
|
|
1231
|
-
|
|
1232
|
-
el.
|
|
1233
|
-
(0,
|
|
1234
|
-
|
|
1235
|
-
|
|
1255
|
+
const multiple = el.multiple;
|
|
1256
|
+
const assignedValue = multiple ? (0, _vue_shared.isSet)(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0];
|
|
1257
|
+
const pending = el._pendingValue = [multiple, multiple ? (0, _vue_shared.isArray)(assignedValue) ? selectedVal.slice() : selectedVal : assignedValue];
|
|
1258
|
+
try {
|
|
1259
|
+
(set || el[assignKey])(assignedValue);
|
|
1260
|
+
} finally {
|
|
1261
|
+
(0, _vue_runtime_core.nextTick)(() => {
|
|
1262
|
+
if (el._pendingValue === pending) el._pendingValue = void 0;
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1236
1265
|
});
|
|
1237
1266
|
};
|
|
1267
|
+
function isSameSelectValue(value, assignedValue, multiple) {
|
|
1268
|
+
if (!multiple) return (0, _vue_shared.looseEqual)(value, assignedValue);
|
|
1269
|
+
if ((0, _vue_shared.isArray)(value)) return (0, _vue_shared.looseEqual)(value, assignedValue);
|
|
1270
|
+
if ((0, _vue_shared.isSet)(value)) {
|
|
1271
|
+
if (value.size !== assignedValue.length) return false;
|
|
1272
|
+
for (const item of assignedValue) if (!value.has(item)) return false;
|
|
1273
|
+
return true;
|
|
1274
|
+
}
|
|
1275
|
+
return false;
|
|
1276
|
+
}
|
|
1238
1277
|
/**
|
|
1239
1278
|
* @internal
|
|
1240
1279
|
*/
|
|
1241
1280
|
const vModelSetSelected = (el, value) => {
|
|
1242
|
-
|
|
1281
|
+
el._modelValue = value;
|
|
1282
|
+
const pending = el._pendingValue;
|
|
1283
|
+
el._pendingValue = void 0;
|
|
1284
|
+
if (pending && pending[0] === el.multiple && isSameSelectValue(value, pending[1], pending[0])) return;
|
|
1285
|
+
setSelected(el, value);
|
|
1286
|
+
};
|
|
1287
|
+
function setSelected(el, value) {
|
|
1243
1288
|
const isMultiple = el.multiple;
|
|
1244
1289
|
const isArrayValue = (0, _vue_shared.isArray)(value);
|
|
1245
1290
|
if (isMultiple && !isArrayValue && !(0, _vue_shared.isSet)(value)) return;
|
|
1246
1291
|
for (let i = 0, l = el.options.length; i < l; i++) {
|
|
1247
1292
|
const option = el.options[i];
|
|
1248
1293
|
const optionValue = getValue(option);
|
|
1249
|
-
if (isMultiple)
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1294
|
+
if (isMultiple) {
|
|
1295
|
+
if (isArrayValue) {
|
|
1296
|
+
const optionType = typeof optionValue;
|
|
1297
|
+
if (optionType === "string" || optionType === "number") option.selected = value.some((v) => String(v) === String(optionValue));
|
|
1298
|
+
else option.selected = (0, _vue_shared.looseIndexOf)(value, optionValue) > -1;
|
|
1299
|
+
} else option.selected = value.has(optionValue);
|
|
1300
|
+
} else if ((0, _vue_shared.looseEqual)(getValue(option), value)) {
|
|
1255
1301
|
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
1256
1302
|
return;
|
|
1257
1303
|
}
|
|
1258
1304
|
}
|
|
1259
1305
|
if (!isMultiple && el.selectedIndex !== -1) el.selectedIndex = -1;
|
|
1260
|
-
}
|
|
1306
|
+
}
|
|
1261
1307
|
/**
|
|
1262
1308
|
* @internal retrieve raw value set via :value bindings
|
|
1263
1309
|
*/
|
|
@@ -1377,7 +1423,7 @@ const withKeys = (fn, modifiers) => {
|
|
|
1377
1423
|
};
|
|
1378
1424
|
//#endregion
|
|
1379
1425
|
//#region packages/runtime-dom/src/index.ts
|
|
1380
|
-
const rendererOptions =
|
|
1426
|
+
const rendererOptions = /*@__PURE__*/ (0, _vue_shared.extend)({ patchProp }, nodeOps);
|
|
1381
1427
|
let renderer;
|
|
1382
1428
|
let enabledHydration = false;
|
|
1383
1429
|
function ensureRenderer() {
|