@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
package/dist/runtime-dom.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
**/
|
|
@@ -492,11 +492,11 @@ function patchStyle(el, prev, next) {
|
|
|
492
492
|
}
|
|
493
493
|
const semicolonRE = /[^\\];\s*$/;
|
|
494
494
|
const importantRE = /\s*!important$/;
|
|
495
|
-
function setStyle(style, name,
|
|
496
|
-
if (shared.isArray(
|
|
497
|
-
|
|
495
|
+
function setStyle(style, name, rawVal) {
|
|
496
|
+
if (shared.isArray(rawVal)) {
|
|
497
|
+
rawVal.forEach((v) => setStyle(style, name, v));
|
|
498
498
|
} else {
|
|
499
|
-
|
|
499
|
+
const val = rawVal == null ? "" : String(rawVal);
|
|
500
500
|
{
|
|
501
501
|
if (semicolonRE.test(val)) {
|
|
502
502
|
runtimeCore.warn(
|
|
@@ -569,8 +569,7 @@ function patchDOMProp(el, key, value, parentComponent, attrName) {
|
|
|
569
569
|
return;
|
|
570
570
|
}
|
|
571
571
|
const tag = el.tagName;
|
|
572
|
-
if (key === "value" && tag
|
|
573
|
-
!tag.includes("-")) {
|
|
572
|
+
if (key === "value" && shared.canSetValueDirectly(tag)) {
|
|
574
573
|
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
|
575
574
|
const newValue = value == null ? (
|
|
576
575
|
// #11647: value should be set as empty string for null and undefined,
|
|
@@ -698,8 +697,6 @@ function patchStopImmediatePropagation(e, value) {
|
|
|
698
697
|
}
|
|
699
698
|
}
|
|
700
699
|
|
|
701
|
-
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
|
702
|
-
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
703
700
|
const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
|
704
701
|
const isSVG = namespace === "svg";
|
|
705
702
|
if (key === "class") {
|
|
@@ -734,30 +731,15 @@ function shouldSetAsProp(el, key, value, isSVG) {
|
|
|
734
731
|
if (key === "innerHTML" || key === "textContent") {
|
|
735
732
|
return true;
|
|
736
733
|
}
|
|
737
|
-
if (key in el && isNativeOn(key) && shared.isFunction(value)) {
|
|
734
|
+
if (key in el && shared.isNativeOn(key) && shared.isFunction(value)) {
|
|
738
735
|
return true;
|
|
739
736
|
}
|
|
740
737
|
return false;
|
|
741
738
|
}
|
|
742
|
-
if (
|
|
739
|
+
if (shared.shouldSetAsAttr(el.tagName, key)) {
|
|
743
740
|
return false;
|
|
744
741
|
}
|
|
745
|
-
if (key
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
748
|
-
if (key === "list" && el.tagName === "INPUT") {
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
751
|
-
if (key === "type" && el.tagName === "TEXTAREA") {
|
|
752
|
-
return false;
|
|
753
|
-
}
|
|
754
|
-
if (key === "width" || key === "height") {
|
|
755
|
-
const tag = el.tagName;
|
|
756
|
-
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
if (isNativeOn(key) && shared.isString(value)) {
|
|
742
|
+
if (shared.isNativeOn(key) && shared.isString(value)) {
|
|
761
743
|
return false;
|
|
762
744
|
}
|
|
763
745
|
return key in el;
|
|
@@ -924,9 +906,10 @@ class VueElement extends BaseClass {
|
|
|
924
906
|
};
|
|
925
907
|
const asyncDef = this._def.__asyncLoader;
|
|
926
908
|
if (asyncDef) {
|
|
927
|
-
this._pendingResolve = asyncDef().then(
|
|
928
|
-
|
|
929
|
-
|
|
909
|
+
this._pendingResolve = asyncDef().then((def) => {
|
|
910
|
+
def.configureApp = this._def.configureApp;
|
|
911
|
+
resolve(this._def = def, true);
|
|
912
|
+
});
|
|
930
913
|
} else {
|
|
931
914
|
resolve(this._def);
|
|
932
915
|
}
|
|
@@ -1361,28 +1344,12 @@ const assignKey = Symbol("_assign");
|
|
|
1361
1344
|
const vModelText = {
|
|
1362
1345
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1363
1346
|
el[assignKey] = getModelAssigner(vnode);
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1371
|
-
if (castToNumber) {
|
|
1372
|
-
domValue = shared.looseToNumber(domValue);
|
|
1373
|
-
}
|
|
1374
|
-
el[assignKey](domValue);
|
|
1375
|
-
});
|
|
1376
|
-
if (trim) {
|
|
1377
|
-
addEventListener(el, "change", () => {
|
|
1378
|
-
el.value = el.value.trim();
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
if (!lazy) {
|
|
1382
|
-
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1383
|
-
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1384
|
-
addEventListener(el, "change", onCompositionEnd);
|
|
1385
|
-
}
|
|
1347
|
+
vModelTextInit(
|
|
1348
|
+
el,
|
|
1349
|
+
trim,
|
|
1350
|
+
number || !!(vnode.props && vnode.props.type === "number"),
|
|
1351
|
+
lazy
|
|
1352
|
+
);
|
|
1386
1353
|
},
|
|
1387
1354
|
// set value on mounted so it's after min/max for type="range"
|
|
1388
1355
|
mounted(el, { value }) {
|
|
@@ -1390,70 +1357,111 @@ const vModelText = {
|
|
|
1390
1357
|
},
|
|
1391
1358
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1392
1359
|
el[assignKey] = getModelAssigner(vnode);
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1360
|
+
vModelTextUpdate(el, oldValue, value, trim, number, lazy);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
const vModelTextInit = (el, trim, number, lazy, set) => {
|
|
1364
|
+
addEventListener(el, lazy ? "change" : "input", (e) => {
|
|
1365
|
+
if (e.target.composing) return;
|
|
1366
|
+
let domValue = el.value;
|
|
1367
|
+
if (trim) {
|
|
1368
|
+
domValue = domValue.trim();
|
|
1369
|
+
}
|
|
1370
|
+
if (number || el.type === "number") {
|
|
1371
|
+
domValue = shared.looseToNumber(domValue);
|
|
1372
|
+
}
|
|
1373
|
+
(0, el[assignKey])(domValue);
|
|
1374
|
+
});
|
|
1375
|
+
if (trim) {
|
|
1376
|
+
addEventListener(el, "change", () => {
|
|
1377
|
+
el.value = el.value.trim();
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
if (!lazy) {
|
|
1381
|
+
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1382
|
+
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1383
|
+
addEventListener(el, "change", onCompositionEnd);
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
const vModelTextUpdate = (el, oldValue, value, trim, number, lazy) => {
|
|
1387
|
+
if (el.composing) return;
|
|
1388
|
+
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value;
|
|
1389
|
+
const newValue = value == null ? "" : value;
|
|
1390
|
+
if (elValue === newValue) {
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
if (document.activeElement === el && el.type !== "range") {
|
|
1394
|
+
if (lazy && value === oldValue) {
|
|
1397
1395
|
return;
|
|
1398
1396
|
}
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1401
|
-
return;
|
|
1402
|
-
}
|
|
1403
|
-
if (trim && el.value.trim() === newValue) {
|
|
1404
|
-
return;
|
|
1405
|
-
}
|
|
1397
|
+
if (trim && el.value.trim() === newValue) {
|
|
1398
|
+
return;
|
|
1406
1399
|
}
|
|
1407
|
-
el.value = newValue;
|
|
1408
1400
|
}
|
|
1401
|
+
el.value = newValue;
|
|
1409
1402
|
};
|
|
1410
1403
|
const vModelCheckbox = {
|
|
1411
1404
|
// #4096 array checkboxes need to be deep traversed
|
|
1412
1405
|
deep: true,
|
|
1413
1406
|
created(el, _, vnode) {
|
|
1414
1407
|
el[assignKey] = getModelAssigner(vnode);
|
|
1415
|
-
|
|
1416
|
-
const modelValue = el._modelValue;
|
|
1417
|
-
const elementValue = getValue(el);
|
|
1418
|
-
const checked = el.checked;
|
|
1419
|
-
const assign = el[assignKey];
|
|
1420
|
-
if (shared.isArray(modelValue)) {
|
|
1421
|
-
const index = shared.looseIndexOf(modelValue, elementValue);
|
|
1422
|
-
const found = index !== -1;
|
|
1423
|
-
if (checked && !found) {
|
|
1424
|
-
assign(modelValue.concat(elementValue));
|
|
1425
|
-
} else if (!checked && found) {
|
|
1426
|
-
const filtered = [...modelValue];
|
|
1427
|
-
filtered.splice(index, 1);
|
|
1428
|
-
assign(filtered);
|
|
1429
|
-
}
|
|
1430
|
-
} else if (shared.isSet(modelValue)) {
|
|
1431
|
-
const cloned = new Set(modelValue);
|
|
1432
|
-
if (checked) {
|
|
1433
|
-
cloned.add(elementValue);
|
|
1434
|
-
} else {
|
|
1435
|
-
cloned.delete(elementValue);
|
|
1436
|
-
}
|
|
1437
|
-
assign(cloned);
|
|
1438
|
-
} else {
|
|
1439
|
-
assign(getCheckboxValue(el, checked));
|
|
1440
|
-
}
|
|
1441
|
-
});
|
|
1408
|
+
vModelCheckboxInit(el);
|
|
1442
1409
|
},
|
|
1443
1410
|
// set initial checked on mount to wait for true-value/false-value
|
|
1444
|
-
mounted
|
|
1411
|
+
mounted(el, binding, vnode) {
|
|
1412
|
+
vModelCheckboxUpdate(
|
|
1413
|
+
el,
|
|
1414
|
+
binding.oldValue,
|
|
1415
|
+
binding.value,
|
|
1416
|
+
vnode.props.value
|
|
1417
|
+
);
|
|
1418
|
+
},
|
|
1445
1419
|
beforeUpdate(el, binding, vnode) {
|
|
1446
1420
|
el[assignKey] = getModelAssigner(vnode);
|
|
1447
|
-
|
|
1421
|
+
vModelCheckboxUpdate(
|
|
1422
|
+
el,
|
|
1423
|
+
binding.oldValue,
|
|
1424
|
+
binding.value,
|
|
1425
|
+
vnode.props.value
|
|
1426
|
+
);
|
|
1448
1427
|
}
|
|
1449
1428
|
};
|
|
1450
|
-
|
|
1429
|
+
const vModelCheckboxInit = (el, set) => {
|
|
1430
|
+
addEventListener(el, "change", () => {
|
|
1431
|
+
const assign = el[assignKey];
|
|
1432
|
+
const modelValue = el._modelValue;
|
|
1433
|
+
const elementValue = getValue(el);
|
|
1434
|
+
const checked = el.checked;
|
|
1435
|
+
if (shared.isArray(modelValue)) {
|
|
1436
|
+
const index = shared.looseIndexOf(modelValue, elementValue);
|
|
1437
|
+
const found = index !== -1;
|
|
1438
|
+
if (checked && !found) {
|
|
1439
|
+
assign(modelValue.concat(elementValue));
|
|
1440
|
+
} else if (!checked && found) {
|
|
1441
|
+
const filtered = [...modelValue];
|
|
1442
|
+
filtered.splice(index, 1);
|
|
1443
|
+
assign(filtered);
|
|
1444
|
+
}
|
|
1445
|
+
} else if (shared.isSet(modelValue)) {
|
|
1446
|
+
const cloned = new Set(modelValue);
|
|
1447
|
+
if (checked) {
|
|
1448
|
+
cloned.add(elementValue);
|
|
1449
|
+
} else {
|
|
1450
|
+
cloned.delete(elementValue);
|
|
1451
|
+
}
|
|
1452
|
+
assign(cloned);
|
|
1453
|
+
} else {
|
|
1454
|
+
assign(getCheckboxValue(el, checked));
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1457
|
+
};
|
|
1458
|
+
const vModelCheckboxUpdate = (el, oldValue, value, rawValue = getValue(el)) => {
|
|
1451
1459
|
el._modelValue = value;
|
|
1452
1460
|
let checked;
|
|
1453
1461
|
if (shared.isArray(value)) {
|
|
1454
|
-
checked = shared.looseIndexOf(value,
|
|
1462
|
+
checked = shared.looseIndexOf(value, rawValue) > -1;
|
|
1455
1463
|
} else if (shared.isSet(value)) {
|
|
1456
|
-
checked = value.has(
|
|
1464
|
+
checked = value.has(rawValue);
|
|
1457
1465
|
} else {
|
|
1458
1466
|
if (value === oldValue) return;
|
|
1459
1467
|
checked = shared.looseEqual(value, getCheckboxValue(el, true));
|
|
@@ -1461,7 +1469,7 @@ function setChecked(el, { value, oldValue }, vnode) {
|
|
|
1461
1469
|
if (el.checked !== checked) {
|
|
1462
1470
|
el.checked = checked;
|
|
1463
1471
|
}
|
|
1464
|
-
}
|
|
1472
|
+
};
|
|
1465
1473
|
const vModelRadio = {
|
|
1466
1474
|
created(el, { value }, vnode) {
|
|
1467
1475
|
el.checked = shared.looseEqual(value, vnode.props.value);
|
|
@@ -1481,36 +1489,38 @@ const vModelSelect = {
|
|
|
1481
1489
|
// <select multiple> value need to be deep traversed
|
|
1482
1490
|
deep: true,
|
|
1483
1491
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
1484
|
-
|
|
1485
|
-
addEventListener(el, "change", () => {
|
|
1486
|
-
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1487
|
-
(o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
|
|
1488
|
-
);
|
|
1489
|
-
el[assignKey](
|
|
1490
|
-
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1491
|
-
);
|
|
1492
|
-
el._assigning = true;
|
|
1493
|
-
runtimeCore.nextTick(() => {
|
|
1494
|
-
el._assigning = false;
|
|
1495
|
-
});
|
|
1496
|
-
});
|
|
1492
|
+
vModelSelectInit(el, value, number);
|
|
1497
1493
|
el[assignKey] = getModelAssigner(vnode);
|
|
1498
1494
|
},
|
|
1499
1495
|
// set value in mounted & updated because <select> relies on its children
|
|
1500
1496
|
// <option>s.
|
|
1501
1497
|
mounted(el, { value }) {
|
|
1502
|
-
|
|
1498
|
+
vModelSetSelected(el, value);
|
|
1503
1499
|
},
|
|
1504
1500
|
beforeUpdate(el, _binding, vnode) {
|
|
1505
1501
|
el[assignKey] = getModelAssigner(vnode);
|
|
1506
1502
|
},
|
|
1507
1503
|
updated(el, { value }) {
|
|
1508
|
-
|
|
1509
|
-
setSelected(el, value);
|
|
1510
|
-
}
|
|
1504
|
+
vModelSetSelected(el, value);
|
|
1511
1505
|
}
|
|
1512
1506
|
};
|
|
1513
|
-
|
|
1507
|
+
const vModelSelectInit = (el, value, number, set) => {
|
|
1508
|
+
const isSetModel = shared.isSet(value);
|
|
1509
|
+
addEventListener(el, "change", () => {
|
|
1510
|
+
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1511
|
+
(o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
|
|
1512
|
+
);
|
|
1513
|
+
(0, el[assignKey])(
|
|
1514
|
+
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1515
|
+
);
|
|
1516
|
+
el._assigning = true;
|
|
1517
|
+
runtimeCore.nextTick(() => {
|
|
1518
|
+
el._assigning = false;
|
|
1519
|
+
});
|
|
1520
|
+
});
|
|
1521
|
+
};
|
|
1522
|
+
const vModelSetSelected = (el, value) => {
|
|
1523
|
+
if (el._assigning) return;
|
|
1514
1524
|
const isMultiple = el.multiple;
|
|
1515
1525
|
const isArrayValue = shared.isArray(value);
|
|
1516
1526
|
if (isMultiple && !isArrayValue && !shared.isSet(value)) {
|
|
@@ -1541,13 +1551,20 @@ function setSelected(el, value) {
|
|
|
1541
1551
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
1542
1552
|
el.selectedIndex = -1;
|
|
1543
1553
|
}
|
|
1544
|
-
}
|
|
1554
|
+
};
|
|
1545
1555
|
function getValue(el) {
|
|
1546
1556
|
return "_value" in el ? el._value : el.value;
|
|
1547
1557
|
}
|
|
1548
1558
|
function getCheckboxValue(el, checked) {
|
|
1549
1559
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
1550
|
-
|
|
1560
|
+
if (key in el) {
|
|
1561
|
+
return el[key];
|
|
1562
|
+
}
|
|
1563
|
+
const attr = checked ? "true-value" : "false-value";
|
|
1564
|
+
if (el.hasAttribute(attr)) {
|
|
1565
|
+
return el.getAttribute(attr);
|
|
1566
|
+
}
|
|
1567
|
+
return checked;
|
|
1551
1568
|
}
|
|
1552
1569
|
const vModelDynamic = {
|
|
1553
1570
|
created(el, binding, vnode) {
|