@vue/runtime-dom 3.5.16 → 3.6.0-alpha.1
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 +134 -117
- package/dist/runtime-dom.cjs.prod.js +134 -117
- package/dist/runtime-dom.d.ts +6 -6
- package/dist/runtime-dom.esm-browser.js +1991 -1537
- package/dist/runtime-dom.esm-browser.prod.js +3 -3
- package/dist/runtime-dom.esm-bundler.js +137 -119
- package/dist/runtime-dom.global.js +1914 -1460
- package/dist/runtime-dom.global.prod.js +3 -3
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-dom v3.
|
|
2
|
+
* @vue/runtime-dom v3.6.0-alpha.1
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
6
|
import { warn, BaseTransitionPropsValidators, h, BaseTransition, assertNumber, getCurrentInstance, onBeforeUpdate, queuePostFlushCb, onMounted, watch, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, unref, createVNode, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, Text, createRenderer, createHydrationRenderer, isRuntimeOnly } from '@vue/runtime-core';
|
|
7
7
|
export * from '@vue/runtime-core';
|
|
8
|
-
import { extend, isObject, toNumber, isArray, NOOP, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isSymbol, isFunction, isOn, isModelListener, camelize as camelize$1, isPlainObject, hasOwn, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet,
|
|
8
|
+
import { extend, isObject, toNumber, isArray, NOOP, normalizeCssVarValue, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isSymbol, canSetValueDirectly, isFunction, isNativeOn, shouldSetAsAttr, isOn, isModelListener, camelize as camelize$1, isPlainObject, hasOwn, EMPTY_OBJ, looseEqual, looseToNumber, looseIndexOf, isSet, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
|
|
9
9
|
|
|
10
10
|
let policy = void 0;
|
|
11
11
|
const tt = typeof window !== "undefined" && window.trustedTypes;
|
|
@@ -498,8 +498,9 @@ function setVarsOnNode(el, vars) {
|
|
|
498
498
|
const style = el.style;
|
|
499
499
|
let cssText = "";
|
|
500
500
|
for (const key in vars) {
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
const value = normalizeCssVarValue(vars[key]);
|
|
502
|
+
style.setProperty(`--${key}`, value);
|
|
503
|
+
cssText += `--${key}: ${value};`;
|
|
503
504
|
}
|
|
504
505
|
style[CSS_VAR_TEXT] = cssText;
|
|
505
506
|
}
|
|
@@ -556,11 +557,11 @@ function patchStyle(el, prev, next) {
|
|
|
556
557
|
}
|
|
557
558
|
const semicolonRE = /[^\\];\s*$/;
|
|
558
559
|
const importantRE = /\s*!important$/;
|
|
559
|
-
function setStyle(style, name,
|
|
560
|
-
if (isArray(
|
|
561
|
-
|
|
560
|
+
function setStyle(style, name, rawVal) {
|
|
561
|
+
if (isArray(rawVal)) {
|
|
562
|
+
rawVal.forEach((v) => setStyle(style, name, v));
|
|
562
563
|
} else {
|
|
563
|
-
|
|
564
|
+
const val = rawVal == null ? "" : String(rawVal);
|
|
564
565
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
565
566
|
if (semicolonRE.test(val)) {
|
|
566
567
|
warn(
|
|
@@ -633,8 +634,7 @@ function patchDOMProp(el, key, value, parentComponent, attrName) {
|
|
|
633
634
|
return;
|
|
634
635
|
}
|
|
635
636
|
const tag = el.tagName;
|
|
636
|
-
if (key === "value" && tag
|
|
637
|
-
!tag.includes("-")) {
|
|
637
|
+
if (key === "value" && canSetValueDirectly(tag)) {
|
|
638
638
|
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
|
639
639
|
const newValue = value == null ? (
|
|
640
640
|
// #11647: value should be set as empty string for null and undefined,
|
|
@@ -762,8 +762,6 @@ function patchStopImmediatePropagation(e, value) {
|
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
|
|
765
|
-
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
|
766
|
-
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
767
765
|
const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
|
768
766
|
const isSVG = namespace === "svg";
|
|
769
767
|
if (key === "class") {
|
|
@@ -803,24 +801,9 @@ function shouldSetAsProp(el, key, value, isSVG) {
|
|
|
803
801
|
}
|
|
804
802
|
return false;
|
|
805
803
|
}
|
|
806
|
-
if (
|
|
804
|
+
if (shouldSetAsAttr(el.tagName, key)) {
|
|
807
805
|
return false;
|
|
808
806
|
}
|
|
809
|
-
if (key === "form") {
|
|
810
|
-
return false;
|
|
811
|
-
}
|
|
812
|
-
if (key === "list" && el.tagName === "INPUT") {
|
|
813
|
-
return false;
|
|
814
|
-
}
|
|
815
|
-
if (key === "type" && el.tagName === "TEXTAREA") {
|
|
816
|
-
return false;
|
|
817
|
-
}
|
|
818
|
-
if (key === "width" || key === "height") {
|
|
819
|
-
const tag = el.tagName;
|
|
820
|
-
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
|
821
|
-
return false;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
807
|
if (isNativeOn(key) && isString(value)) {
|
|
825
808
|
return false;
|
|
826
809
|
}
|
|
@@ -988,9 +971,10 @@ class VueElement extends BaseClass {
|
|
|
988
971
|
};
|
|
989
972
|
const asyncDef = this._def.__asyncLoader;
|
|
990
973
|
if (asyncDef) {
|
|
991
|
-
this._pendingResolve = asyncDef().then(
|
|
992
|
-
|
|
993
|
-
|
|
974
|
+
this._pendingResolve = asyncDef().then((def) => {
|
|
975
|
+
def.configureApp = this._def.configureApp;
|
|
976
|
+
resolve(this._def = def, true);
|
|
977
|
+
});
|
|
994
978
|
} else {
|
|
995
979
|
resolve(this._def);
|
|
996
980
|
}
|
|
@@ -1425,28 +1409,12 @@ const assignKey = Symbol("_assign");
|
|
|
1425
1409
|
const vModelText = {
|
|
1426
1410
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1427
1411
|
el[assignKey] = getModelAssigner(vnode);
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1435
|
-
if (castToNumber) {
|
|
1436
|
-
domValue = looseToNumber(domValue);
|
|
1437
|
-
}
|
|
1438
|
-
el[assignKey](domValue);
|
|
1439
|
-
});
|
|
1440
|
-
if (trim) {
|
|
1441
|
-
addEventListener(el, "change", () => {
|
|
1442
|
-
el.value = el.value.trim();
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1445
|
-
if (!lazy) {
|
|
1446
|
-
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1447
|
-
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1448
|
-
addEventListener(el, "change", onCompositionEnd);
|
|
1449
|
-
}
|
|
1412
|
+
vModelTextInit(
|
|
1413
|
+
el,
|
|
1414
|
+
trim,
|
|
1415
|
+
number || !!(vnode.props && vnode.props.type === "number"),
|
|
1416
|
+
lazy
|
|
1417
|
+
);
|
|
1450
1418
|
},
|
|
1451
1419
|
// set value on mounted so it's after min/max for type="range"
|
|
1452
1420
|
mounted(el, { value }) {
|
|
@@ -1454,70 +1422,111 @@ const vModelText = {
|
|
|
1454
1422
|
},
|
|
1455
1423
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1456
1424
|
el[assignKey] = getModelAssigner(vnode);
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1425
|
+
vModelTextUpdate(el, oldValue, value, trim, number, lazy);
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
const vModelTextInit = (el, trim, number, lazy, set) => {
|
|
1429
|
+
addEventListener(el, lazy ? "change" : "input", (e) => {
|
|
1430
|
+
if (e.target.composing) return;
|
|
1431
|
+
let domValue = el.value;
|
|
1432
|
+
if (trim) {
|
|
1433
|
+
domValue = domValue.trim();
|
|
1434
|
+
}
|
|
1435
|
+
if (number || el.type === "number") {
|
|
1436
|
+
domValue = looseToNumber(domValue);
|
|
1437
|
+
}
|
|
1438
|
+
(set || el[assignKey])(domValue);
|
|
1439
|
+
});
|
|
1440
|
+
if (trim) {
|
|
1441
|
+
addEventListener(el, "change", () => {
|
|
1442
|
+
el.value = el.value.trim();
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
if (!lazy) {
|
|
1446
|
+
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1447
|
+
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1448
|
+
addEventListener(el, "change", onCompositionEnd);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
const vModelTextUpdate = (el, oldValue, value, trim, number, lazy) => {
|
|
1452
|
+
if (el.composing) return;
|
|
1453
|
+
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
|
|
1454
|
+
const newValue = value == null ? "" : value;
|
|
1455
|
+
if (elValue === newValue) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (document.activeElement === el && el.type !== "range") {
|
|
1459
|
+
if (lazy && value === oldValue) {
|
|
1461
1460
|
return;
|
|
1462
1461
|
}
|
|
1463
|
-
if (
|
|
1464
|
-
|
|
1465
|
-
return;
|
|
1466
|
-
}
|
|
1467
|
-
if (trim && el.value.trim() === newValue) {
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
1462
|
+
if (trim && el.value.trim() === newValue) {
|
|
1463
|
+
return;
|
|
1470
1464
|
}
|
|
1471
|
-
el.value = newValue;
|
|
1472
1465
|
}
|
|
1466
|
+
el.value = newValue;
|
|
1473
1467
|
};
|
|
1474
1468
|
const vModelCheckbox = {
|
|
1475
1469
|
// #4096 array checkboxes need to be deep traversed
|
|
1476
1470
|
deep: true,
|
|
1477
1471
|
created(el, _, vnode) {
|
|
1478
1472
|
el[assignKey] = getModelAssigner(vnode);
|
|
1479
|
-
|
|
1480
|
-
const modelValue = el._modelValue;
|
|
1481
|
-
const elementValue = getValue(el);
|
|
1482
|
-
const checked = el.checked;
|
|
1483
|
-
const assign = el[assignKey];
|
|
1484
|
-
if (isArray(modelValue)) {
|
|
1485
|
-
const index = looseIndexOf(modelValue, elementValue);
|
|
1486
|
-
const found = index !== -1;
|
|
1487
|
-
if (checked && !found) {
|
|
1488
|
-
assign(modelValue.concat(elementValue));
|
|
1489
|
-
} else if (!checked && found) {
|
|
1490
|
-
const filtered = [...modelValue];
|
|
1491
|
-
filtered.splice(index, 1);
|
|
1492
|
-
assign(filtered);
|
|
1493
|
-
}
|
|
1494
|
-
} else if (isSet(modelValue)) {
|
|
1495
|
-
const cloned = new Set(modelValue);
|
|
1496
|
-
if (checked) {
|
|
1497
|
-
cloned.add(elementValue);
|
|
1498
|
-
} else {
|
|
1499
|
-
cloned.delete(elementValue);
|
|
1500
|
-
}
|
|
1501
|
-
assign(cloned);
|
|
1502
|
-
} else {
|
|
1503
|
-
assign(getCheckboxValue(el, checked));
|
|
1504
|
-
}
|
|
1505
|
-
});
|
|
1473
|
+
vModelCheckboxInit(el);
|
|
1506
1474
|
},
|
|
1507
1475
|
// set initial checked on mount to wait for true-value/false-value
|
|
1508
|
-
mounted
|
|
1476
|
+
mounted(el, binding, vnode) {
|
|
1477
|
+
vModelCheckboxUpdate(
|
|
1478
|
+
el,
|
|
1479
|
+
binding.oldValue,
|
|
1480
|
+
binding.value,
|
|
1481
|
+
vnode.props.value
|
|
1482
|
+
);
|
|
1483
|
+
},
|
|
1509
1484
|
beforeUpdate(el, binding, vnode) {
|
|
1510
1485
|
el[assignKey] = getModelAssigner(vnode);
|
|
1511
|
-
|
|
1486
|
+
vModelCheckboxUpdate(
|
|
1487
|
+
el,
|
|
1488
|
+
binding.oldValue,
|
|
1489
|
+
binding.value,
|
|
1490
|
+
vnode.props.value
|
|
1491
|
+
);
|
|
1512
1492
|
}
|
|
1513
1493
|
};
|
|
1514
|
-
|
|
1494
|
+
const vModelCheckboxInit = (el, set) => {
|
|
1495
|
+
addEventListener(el, "change", () => {
|
|
1496
|
+
const assign = set || el[assignKey];
|
|
1497
|
+
const modelValue = el._modelValue;
|
|
1498
|
+
const elementValue = getValue(el);
|
|
1499
|
+
const checked = el.checked;
|
|
1500
|
+
if (isArray(modelValue)) {
|
|
1501
|
+
const index = looseIndexOf(modelValue, elementValue);
|
|
1502
|
+
const found = index !== -1;
|
|
1503
|
+
if (checked && !found) {
|
|
1504
|
+
assign(modelValue.concat(elementValue));
|
|
1505
|
+
} else if (!checked && found) {
|
|
1506
|
+
const filtered = [...modelValue];
|
|
1507
|
+
filtered.splice(index, 1);
|
|
1508
|
+
assign(filtered);
|
|
1509
|
+
}
|
|
1510
|
+
} else if (isSet(modelValue)) {
|
|
1511
|
+
const cloned = new Set(modelValue);
|
|
1512
|
+
if (checked) {
|
|
1513
|
+
cloned.add(elementValue);
|
|
1514
|
+
} else {
|
|
1515
|
+
cloned.delete(elementValue);
|
|
1516
|
+
}
|
|
1517
|
+
assign(cloned);
|
|
1518
|
+
} else {
|
|
1519
|
+
assign(getCheckboxValue(el, checked));
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
};
|
|
1523
|
+
const vModelCheckboxUpdate = (el, oldValue, value, rawValue = getValue(el)) => {
|
|
1515
1524
|
el._modelValue = value;
|
|
1516
1525
|
let checked;
|
|
1517
1526
|
if (isArray(value)) {
|
|
1518
|
-
checked = looseIndexOf(value,
|
|
1527
|
+
checked = looseIndexOf(value, rawValue) > -1;
|
|
1519
1528
|
} else if (isSet(value)) {
|
|
1520
|
-
checked = value.has(
|
|
1529
|
+
checked = value.has(rawValue);
|
|
1521
1530
|
} else {
|
|
1522
1531
|
if (value === oldValue) return;
|
|
1523
1532
|
checked = looseEqual(value, getCheckboxValue(el, true));
|
|
@@ -1525,7 +1534,7 @@ function setChecked(el, { value, oldValue }, vnode) {
|
|
|
1525
1534
|
if (el.checked !== checked) {
|
|
1526
1535
|
el.checked = checked;
|
|
1527
1536
|
}
|
|
1528
|
-
}
|
|
1537
|
+
};
|
|
1529
1538
|
const vModelRadio = {
|
|
1530
1539
|
created(el, { value }, vnode) {
|
|
1531
1540
|
el.checked = looseEqual(value, vnode.props.value);
|
|
@@ -1545,36 +1554,38 @@ const vModelSelect = {
|
|
|
1545
1554
|
// <select multiple> value need to be deep traversed
|
|
1546
1555
|
deep: true,
|
|
1547
1556
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
1548
|
-
|
|
1549
|
-
addEventListener(el, "change", () => {
|
|
1550
|
-
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1551
|
-
(o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
|
1552
|
-
);
|
|
1553
|
-
el[assignKey](
|
|
1554
|
-
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1555
|
-
);
|
|
1556
|
-
el._assigning = true;
|
|
1557
|
-
nextTick(() => {
|
|
1558
|
-
el._assigning = false;
|
|
1559
|
-
});
|
|
1560
|
-
});
|
|
1557
|
+
vModelSelectInit(el, value, number);
|
|
1561
1558
|
el[assignKey] = getModelAssigner(vnode);
|
|
1562
1559
|
},
|
|
1563
1560
|
// set value in mounted & updated because <select> relies on its children
|
|
1564
1561
|
// <option>s.
|
|
1565
1562
|
mounted(el, { value }) {
|
|
1566
|
-
|
|
1563
|
+
vModelSetSelected(el, value);
|
|
1567
1564
|
},
|
|
1568
1565
|
beforeUpdate(el, _binding, vnode) {
|
|
1569
1566
|
el[assignKey] = getModelAssigner(vnode);
|
|
1570
1567
|
},
|
|
1571
1568
|
updated(el, { value }) {
|
|
1572
|
-
|
|
1573
|
-
setSelected(el, value);
|
|
1574
|
-
}
|
|
1569
|
+
vModelSetSelected(el, value);
|
|
1575
1570
|
}
|
|
1576
1571
|
};
|
|
1577
|
-
|
|
1572
|
+
const vModelSelectInit = (el, value, number, set) => {
|
|
1573
|
+
const isSetModel = isSet(value);
|
|
1574
|
+
addEventListener(el, "change", () => {
|
|
1575
|
+
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1576
|
+
(o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
|
1577
|
+
);
|
|
1578
|
+
(set || el[assignKey])(
|
|
1579
|
+
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1580
|
+
);
|
|
1581
|
+
el._assigning = true;
|
|
1582
|
+
nextTick(() => {
|
|
1583
|
+
el._assigning = false;
|
|
1584
|
+
});
|
|
1585
|
+
});
|
|
1586
|
+
};
|
|
1587
|
+
const vModelSetSelected = (el, value) => {
|
|
1588
|
+
if (el._assigning) return;
|
|
1578
1589
|
const isMultiple = el.multiple;
|
|
1579
1590
|
const isArrayValue = isArray(value);
|
|
1580
1591
|
if (isMultiple && !isArrayValue && !isSet(value)) {
|
|
@@ -1605,13 +1616,20 @@ function setSelected(el, value) {
|
|
|
1605
1616
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
1606
1617
|
el.selectedIndex = -1;
|
|
1607
1618
|
}
|
|
1608
|
-
}
|
|
1619
|
+
};
|
|
1609
1620
|
function getValue(el) {
|
|
1610
1621
|
return "_value" in el ? el._value : el.value;
|
|
1611
1622
|
}
|
|
1612
1623
|
function getCheckboxValue(el, checked) {
|
|
1613
1624
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
1614
|
-
|
|
1625
|
+
if (key in el) {
|
|
1626
|
+
return el[key];
|
|
1627
|
+
}
|
|
1628
|
+
const attr = checked ? "true-value" : "false-value";
|
|
1629
|
+
if (el.hasAttribute(attr)) {
|
|
1630
|
+
return el.getAttribute(attr);
|
|
1631
|
+
}
|
|
1632
|
+
return checked;
|
|
1615
1633
|
}
|
|
1616
1634
|
const vModelDynamic = {
|
|
1617
1635
|
created(el, binding, vnode) {
|
|
@@ -1864,4 +1882,4 @@ const initDirectivesForSSR = () => {
|
|
|
1864
1882
|
}
|
|
1865
1883
|
} ;
|
|
1866
1884
|
|
|
1867
|
-
export { Transition, TransitionGroup, VueElement, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, hydrate, initDirectivesForSSR, render, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, withKeys, withModifiers };
|
|
1885
|
+
export { Transition, TransitionGroup, VueElement, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureRenderer, hydrate, initDirectivesForSSR, normalizeContainer, patchStyle, render, shouldSetAsProp, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers };
|