@vue/runtime-dom 3.5.17 → 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 +130 -114
- package/dist/runtime-dom.cjs.prod.js +130 -114
- package/dist/runtime-dom.d.ts +4 -4
- package/dist/runtime-dom.esm-browser.js +1917 -1474
- package/dist/runtime-dom.esm-browser.prod.js +3 -3
- package/dist/runtime-dom.esm-bundler.js +133 -116
- package/dist/runtime-dom.global.js +1906 -1463
- 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
|
}
|
|
@@ -1426,28 +1409,12 @@ const assignKey = Symbol("_assign");
|
|
|
1426
1409
|
const vModelText = {
|
|
1427
1410
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1428
1411
|
el[assignKey] = getModelAssigner(vnode);
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
}
|
|
1436
|
-
if (castToNumber) {
|
|
1437
|
-
domValue = looseToNumber(domValue);
|
|
1438
|
-
}
|
|
1439
|
-
el[assignKey](domValue);
|
|
1440
|
-
});
|
|
1441
|
-
if (trim) {
|
|
1442
|
-
addEventListener(el, "change", () => {
|
|
1443
|
-
el.value = el.value.trim();
|
|
1444
|
-
});
|
|
1445
|
-
}
|
|
1446
|
-
if (!lazy) {
|
|
1447
|
-
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1448
|
-
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1449
|
-
addEventListener(el, "change", onCompositionEnd);
|
|
1450
|
-
}
|
|
1412
|
+
vModelTextInit(
|
|
1413
|
+
el,
|
|
1414
|
+
trim,
|
|
1415
|
+
number || !!(vnode.props && vnode.props.type === "number"),
|
|
1416
|
+
lazy
|
|
1417
|
+
);
|
|
1451
1418
|
},
|
|
1452
1419
|
// set value on mounted so it's after min/max for type="range"
|
|
1453
1420
|
mounted(el, { value }) {
|
|
@@ -1455,70 +1422,111 @@ const vModelText = {
|
|
|
1455
1422
|
},
|
|
1456
1423
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1457
1424
|
el[assignKey] = getModelAssigner(vnode);
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
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) {
|
|
1462
1460
|
return;
|
|
1463
1461
|
}
|
|
1464
|
-
if (
|
|
1465
|
-
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
if (trim && el.value.trim() === newValue) {
|
|
1469
|
-
return;
|
|
1470
|
-
}
|
|
1462
|
+
if (trim && el.value.trim() === newValue) {
|
|
1463
|
+
return;
|
|
1471
1464
|
}
|
|
1472
|
-
el.value = newValue;
|
|
1473
1465
|
}
|
|
1466
|
+
el.value = newValue;
|
|
1474
1467
|
};
|
|
1475
1468
|
const vModelCheckbox = {
|
|
1476
1469
|
// #4096 array checkboxes need to be deep traversed
|
|
1477
1470
|
deep: true,
|
|
1478
1471
|
created(el, _, vnode) {
|
|
1479
1472
|
el[assignKey] = getModelAssigner(vnode);
|
|
1480
|
-
|
|
1481
|
-
const modelValue = el._modelValue;
|
|
1482
|
-
const elementValue = getValue(el);
|
|
1483
|
-
const checked = el.checked;
|
|
1484
|
-
const assign = el[assignKey];
|
|
1485
|
-
if (isArray(modelValue)) {
|
|
1486
|
-
const index = looseIndexOf(modelValue, elementValue);
|
|
1487
|
-
const found = index !== -1;
|
|
1488
|
-
if (checked && !found) {
|
|
1489
|
-
assign(modelValue.concat(elementValue));
|
|
1490
|
-
} else if (!checked && found) {
|
|
1491
|
-
const filtered = [...modelValue];
|
|
1492
|
-
filtered.splice(index, 1);
|
|
1493
|
-
assign(filtered);
|
|
1494
|
-
}
|
|
1495
|
-
} else if (isSet(modelValue)) {
|
|
1496
|
-
const cloned = new Set(modelValue);
|
|
1497
|
-
if (checked) {
|
|
1498
|
-
cloned.add(elementValue);
|
|
1499
|
-
} else {
|
|
1500
|
-
cloned.delete(elementValue);
|
|
1501
|
-
}
|
|
1502
|
-
assign(cloned);
|
|
1503
|
-
} else {
|
|
1504
|
-
assign(getCheckboxValue(el, checked));
|
|
1505
|
-
}
|
|
1506
|
-
});
|
|
1473
|
+
vModelCheckboxInit(el);
|
|
1507
1474
|
},
|
|
1508
1475
|
// set initial checked on mount to wait for true-value/false-value
|
|
1509
|
-
mounted
|
|
1476
|
+
mounted(el, binding, vnode) {
|
|
1477
|
+
vModelCheckboxUpdate(
|
|
1478
|
+
el,
|
|
1479
|
+
binding.oldValue,
|
|
1480
|
+
binding.value,
|
|
1481
|
+
vnode.props.value
|
|
1482
|
+
);
|
|
1483
|
+
},
|
|
1510
1484
|
beforeUpdate(el, binding, vnode) {
|
|
1511
1485
|
el[assignKey] = getModelAssigner(vnode);
|
|
1512
|
-
|
|
1486
|
+
vModelCheckboxUpdate(
|
|
1487
|
+
el,
|
|
1488
|
+
binding.oldValue,
|
|
1489
|
+
binding.value,
|
|
1490
|
+
vnode.props.value
|
|
1491
|
+
);
|
|
1513
1492
|
}
|
|
1514
1493
|
};
|
|
1515
|
-
|
|
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)) => {
|
|
1516
1524
|
el._modelValue = value;
|
|
1517
1525
|
let checked;
|
|
1518
1526
|
if (isArray(value)) {
|
|
1519
|
-
checked = looseIndexOf(value,
|
|
1527
|
+
checked = looseIndexOf(value, rawValue) > -1;
|
|
1520
1528
|
} else if (isSet(value)) {
|
|
1521
|
-
checked = value.has(
|
|
1529
|
+
checked = value.has(rawValue);
|
|
1522
1530
|
} else {
|
|
1523
1531
|
if (value === oldValue) return;
|
|
1524
1532
|
checked = looseEqual(value, getCheckboxValue(el, true));
|
|
@@ -1526,7 +1534,7 @@ function setChecked(el, { value, oldValue }, vnode) {
|
|
|
1526
1534
|
if (el.checked !== checked) {
|
|
1527
1535
|
el.checked = checked;
|
|
1528
1536
|
}
|
|
1529
|
-
}
|
|
1537
|
+
};
|
|
1530
1538
|
const vModelRadio = {
|
|
1531
1539
|
created(el, { value }, vnode) {
|
|
1532
1540
|
el.checked = looseEqual(value, vnode.props.value);
|
|
@@ -1546,36 +1554,38 @@ const vModelSelect = {
|
|
|
1546
1554
|
// <select multiple> value need to be deep traversed
|
|
1547
1555
|
deep: true,
|
|
1548
1556
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
1549
|
-
|
|
1550
|
-
addEventListener(el, "change", () => {
|
|
1551
|
-
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1552
|
-
(o) => number ? looseToNumber(getValue(o)) : getValue(o)
|
|
1553
|
-
);
|
|
1554
|
-
el[assignKey](
|
|
1555
|
-
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1556
|
-
);
|
|
1557
|
-
el._assigning = true;
|
|
1558
|
-
nextTick(() => {
|
|
1559
|
-
el._assigning = false;
|
|
1560
|
-
});
|
|
1561
|
-
});
|
|
1557
|
+
vModelSelectInit(el, value, number);
|
|
1562
1558
|
el[assignKey] = getModelAssigner(vnode);
|
|
1563
1559
|
},
|
|
1564
1560
|
// set value in mounted & updated because <select> relies on its children
|
|
1565
1561
|
// <option>s.
|
|
1566
1562
|
mounted(el, { value }) {
|
|
1567
|
-
|
|
1563
|
+
vModelSetSelected(el, value);
|
|
1568
1564
|
},
|
|
1569
1565
|
beforeUpdate(el, _binding, vnode) {
|
|
1570
1566
|
el[assignKey] = getModelAssigner(vnode);
|
|
1571
1567
|
},
|
|
1572
1568
|
updated(el, { value }) {
|
|
1573
|
-
|
|
1574
|
-
setSelected(el, value);
|
|
1575
|
-
}
|
|
1569
|
+
vModelSetSelected(el, value);
|
|
1576
1570
|
}
|
|
1577
1571
|
};
|
|
1578
|
-
|
|
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;
|
|
1579
1589
|
const isMultiple = el.multiple;
|
|
1580
1590
|
const isArrayValue = isArray(value);
|
|
1581
1591
|
if (isMultiple && !isArrayValue && !isSet(value)) {
|
|
@@ -1606,13 +1616,20 @@ function setSelected(el, value) {
|
|
|
1606
1616
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
1607
1617
|
el.selectedIndex = -1;
|
|
1608
1618
|
}
|
|
1609
|
-
}
|
|
1619
|
+
};
|
|
1610
1620
|
function getValue(el) {
|
|
1611
1621
|
return "_value" in el ? el._value : el.value;
|
|
1612
1622
|
}
|
|
1613
1623
|
function getCheckboxValue(el, checked) {
|
|
1614
1624
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
1615
|
-
|
|
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;
|
|
1616
1633
|
}
|
|
1617
1634
|
const vModelDynamic = {
|
|
1618
1635
|
created(el, binding, vnode) {
|
|
@@ -1865,4 +1882,4 @@ const initDirectivesForSSR = () => {
|
|
|
1865
1882
|
}
|
|
1866
1883
|
} ;
|
|
1867
1884
|
|
|
1868
|
-
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 };
|