@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,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
|
**/
|
|
@@ -484,11 +484,11 @@ function patchStyle(el, prev, next) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
const importantRE = /\s*!important$/;
|
|
487
|
-
function setStyle(style, name,
|
|
488
|
-
if (shared.isArray(
|
|
489
|
-
|
|
487
|
+
function setStyle(style, name, rawVal) {
|
|
488
|
+
if (shared.isArray(rawVal)) {
|
|
489
|
+
rawVal.forEach((v) => setStyle(style, name, v));
|
|
490
490
|
} else {
|
|
491
|
-
|
|
491
|
+
const val = rawVal == null ? "" : String(rawVal);
|
|
492
492
|
if (name.startsWith("--")) {
|
|
493
493
|
style.setProperty(name, val);
|
|
494
494
|
} else {
|
|
@@ -554,8 +554,7 @@ function patchDOMProp(el, key, value, parentComponent, attrName) {
|
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
556
|
const tag = el.tagName;
|
|
557
|
-
if (key === "value" && tag
|
|
558
|
-
!tag.includes("-")) {
|
|
557
|
+
if (key === "value" && shared.canSetValueDirectly(tag)) {
|
|
559
558
|
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
|
560
559
|
const newValue = value == null ? (
|
|
561
560
|
// #11647: value should be set as empty string for null and undefined,
|
|
@@ -667,8 +666,6 @@ function patchStopImmediatePropagation(e, value) {
|
|
|
667
666
|
}
|
|
668
667
|
}
|
|
669
668
|
|
|
670
|
-
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
|
671
|
-
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
672
669
|
const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
|
|
673
670
|
const isSVG = namespace === "svg";
|
|
674
671
|
if (key === "class") {
|
|
@@ -703,30 +700,15 @@ function shouldSetAsProp(el, key, value, isSVG) {
|
|
|
703
700
|
if (key === "innerHTML" || key === "textContent") {
|
|
704
701
|
return true;
|
|
705
702
|
}
|
|
706
|
-
if (key in el && isNativeOn(key) && shared.isFunction(value)) {
|
|
703
|
+
if (key in el && shared.isNativeOn(key) && shared.isFunction(value)) {
|
|
707
704
|
return true;
|
|
708
705
|
}
|
|
709
706
|
return false;
|
|
710
707
|
}
|
|
711
|
-
if (
|
|
708
|
+
if (shared.shouldSetAsAttr(el.tagName, key)) {
|
|
712
709
|
return false;
|
|
713
710
|
}
|
|
714
|
-
if (key
|
|
715
|
-
return false;
|
|
716
|
-
}
|
|
717
|
-
if (key === "list" && el.tagName === "INPUT") {
|
|
718
|
-
return false;
|
|
719
|
-
}
|
|
720
|
-
if (key === "type" && el.tagName === "TEXTAREA") {
|
|
721
|
-
return false;
|
|
722
|
-
}
|
|
723
|
-
if (key === "width" || key === "height") {
|
|
724
|
-
const tag = el.tagName;
|
|
725
|
-
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
|
726
|
-
return false;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
if (isNativeOn(key) && shared.isString(value)) {
|
|
711
|
+
if (shared.isNativeOn(key) && shared.isString(value)) {
|
|
730
712
|
return false;
|
|
731
713
|
}
|
|
732
714
|
return key in el;
|
|
@@ -884,9 +866,10 @@ class VueElement extends BaseClass {
|
|
|
884
866
|
};
|
|
885
867
|
const asyncDef = this._def.__asyncLoader;
|
|
886
868
|
if (asyncDef) {
|
|
887
|
-
this._pendingResolve = asyncDef().then(
|
|
888
|
-
|
|
889
|
-
|
|
869
|
+
this._pendingResolve = asyncDef().then((def) => {
|
|
870
|
+
def.configureApp = this._def.configureApp;
|
|
871
|
+
resolve(this._def = def, true);
|
|
872
|
+
});
|
|
890
873
|
} else {
|
|
891
874
|
resolve(this._def);
|
|
892
875
|
}
|
|
@@ -1266,28 +1249,12 @@ const assignKey = Symbol("_assign");
|
|
|
1266
1249
|
const vModelText = {
|
|
1267
1250
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1268
1251
|
el[assignKey] = getModelAssigner(vnode);
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
}
|
|
1276
|
-
if (castToNumber) {
|
|
1277
|
-
domValue = shared.looseToNumber(domValue);
|
|
1278
|
-
}
|
|
1279
|
-
el[assignKey](domValue);
|
|
1280
|
-
});
|
|
1281
|
-
if (trim) {
|
|
1282
|
-
addEventListener(el, "change", () => {
|
|
1283
|
-
el.value = el.value.trim();
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
if (!lazy) {
|
|
1287
|
-
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1288
|
-
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1289
|
-
addEventListener(el, "change", onCompositionEnd);
|
|
1290
|
-
}
|
|
1252
|
+
vModelTextInit(
|
|
1253
|
+
el,
|
|
1254
|
+
trim,
|
|
1255
|
+
number || !!(vnode.props && vnode.props.type === "number"),
|
|
1256
|
+
lazy
|
|
1257
|
+
);
|
|
1291
1258
|
},
|
|
1292
1259
|
// set value on mounted so it's after min/max for type="range"
|
|
1293
1260
|
mounted(el, { value }) {
|
|
@@ -1295,70 +1262,111 @@ const vModelText = {
|
|
|
1295
1262
|
},
|
|
1296
1263
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1297
1264
|
el[assignKey] = getModelAssigner(vnode);
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1265
|
+
vModelTextUpdate(el, oldValue, value, trim, number, lazy);
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
const vModelTextInit = (el, trim, number, lazy, set) => {
|
|
1269
|
+
addEventListener(el, lazy ? "change" : "input", (e) => {
|
|
1270
|
+
if (e.target.composing) return;
|
|
1271
|
+
let domValue = el.value;
|
|
1272
|
+
if (trim) {
|
|
1273
|
+
domValue = domValue.trim();
|
|
1274
|
+
}
|
|
1275
|
+
if (number || el.type === "number") {
|
|
1276
|
+
domValue = shared.looseToNumber(domValue);
|
|
1277
|
+
}
|
|
1278
|
+
(0, el[assignKey])(domValue);
|
|
1279
|
+
});
|
|
1280
|
+
if (trim) {
|
|
1281
|
+
addEventListener(el, "change", () => {
|
|
1282
|
+
el.value = el.value.trim();
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
if (!lazy) {
|
|
1286
|
+
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1287
|
+
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1288
|
+
addEventListener(el, "change", onCompositionEnd);
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
const vModelTextUpdate = (el, oldValue, value, trim, number, lazy) => {
|
|
1292
|
+
if (el.composing) return;
|
|
1293
|
+
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value;
|
|
1294
|
+
const newValue = value == null ? "" : value;
|
|
1295
|
+
if (elValue === newValue) {
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (document.activeElement === el && el.type !== "range") {
|
|
1299
|
+
if (lazy && value === oldValue) {
|
|
1302
1300
|
return;
|
|
1303
1301
|
}
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1306
|
-
return;
|
|
1307
|
-
}
|
|
1308
|
-
if (trim && el.value.trim() === newValue) {
|
|
1309
|
-
return;
|
|
1310
|
-
}
|
|
1302
|
+
if (trim && el.value.trim() === newValue) {
|
|
1303
|
+
return;
|
|
1311
1304
|
}
|
|
1312
|
-
el.value = newValue;
|
|
1313
1305
|
}
|
|
1306
|
+
el.value = newValue;
|
|
1314
1307
|
};
|
|
1315
1308
|
const vModelCheckbox = {
|
|
1316
1309
|
// #4096 array checkboxes need to be deep traversed
|
|
1317
1310
|
deep: true,
|
|
1318
1311
|
created(el, _, vnode) {
|
|
1319
1312
|
el[assignKey] = getModelAssigner(vnode);
|
|
1320
|
-
|
|
1321
|
-
const modelValue = el._modelValue;
|
|
1322
|
-
const elementValue = getValue(el);
|
|
1323
|
-
const checked = el.checked;
|
|
1324
|
-
const assign = el[assignKey];
|
|
1325
|
-
if (shared.isArray(modelValue)) {
|
|
1326
|
-
const index = shared.looseIndexOf(modelValue, elementValue);
|
|
1327
|
-
const found = index !== -1;
|
|
1328
|
-
if (checked && !found) {
|
|
1329
|
-
assign(modelValue.concat(elementValue));
|
|
1330
|
-
} else if (!checked && found) {
|
|
1331
|
-
const filtered = [...modelValue];
|
|
1332
|
-
filtered.splice(index, 1);
|
|
1333
|
-
assign(filtered);
|
|
1334
|
-
}
|
|
1335
|
-
} else if (shared.isSet(modelValue)) {
|
|
1336
|
-
const cloned = new Set(modelValue);
|
|
1337
|
-
if (checked) {
|
|
1338
|
-
cloned.add(elementValue);
|
|
1339
|
-
} else {
|
|
1340
|
-
cloned.delete(elementValue);
|
|
1341
|
-
}
|
|
1342
|
-
assign(cloned);
|
|
1343
|
-
} else {
|
|
1344
|
-
assign(getCheckboxValue(el, checked));
|
|
1345
|
-
}
|
|
1346
|
-
});
|
|
1313
|
+
vModelCheckboxInit(el);
|
|
1347
1314
|
},
|
|
1348
1315
|
// set initial checked on mount to wait for true-value/false-value
|
|
1349
|
-
mounted
|
|
1316
|
+
mounted(el, binding, vnode) {
|
|
1317
|
+
vModelCheckboxUpdate(
|
|
1318
|
+
el,
|
|
1319
|
+
binding.oldValue,
|
|
1320
|
+
binding.value,
|
|
1321
|
+
vnode.props.value
|
|
1322
|
+
);
|
|
1323
|
+
},
|
|
1350
1324
|
beforeUpdate(el, binding, vnode) {
|
|
1351
1325
|
el[assignKey] = getModelAssigner(vnode);
|
|
1352
|
-
|
|
1326
|
+
vModelCheckboxUpdate(
|
|
1327
|
+
el,
|
|
1328
|
+
binding.oldValue,
|
|
1329
|
+
binding.value,
|
|
1330
|
+
vnode.props.value
|
|
1331
|
+
);
|
|
1353
1332
|
}
|
|
1354
1333
|
};
|
|
1355
|
-
|
|
1334
|
+
const vModelCheckboxInit = (el, set) => {
|
|
1335
|
+
addEventListener(el, "change", () => {
|
|
1336
|
+
const assign = el[assignKey];
|
|
1337
|
+
const modelValue = el._modelValue;
|
|
1338
|
+
const elementValue = getValue(el);
|
|
1339
|
+
const checked = el.checked;
|
|
1340
|
+
if (shared.isArray(modelValue)) {
|
|
1341
|
+
const index = shared.looseIndexOf(modelValue, elementValue);
|
|
1342
|
+
const found = index !== -1;
|
|
1343
|
+
if (checked && !found) {
|
|
1344
|
+
assign(modelValue.concat(elementValue));
|
|
1345
|
+
} else if (!checked && found) {
|
|
1346
|
+
const filtered = [...modelValue];
|
|
1347
|
+
filtered.splice(index, 1);
|
|
1348
|
+
assign(filtered);
|
|
1349
|
+
}
|
|
1350
|
+
} else if (shared.isSet(modelValue)) {
|
|
1351
|
+
const cloned = new Set(modelValue);
|
|
1352
|
+
if (checked) {
|
|
1353
|
+
cloned.add(elementValue);
|
|
1354
|
+
} else {
|
|
1355
|
+
cloned.delete(elementValue);
|
|
1356
|
+
}
|
|
1357
|
+
assign(cloned);
|
|
1358
|
+
} else {
|
|
1359
|
+
assign(getCheckboxValue(el, checked));
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
};
|
|
1363
|
+
const vModelCheckboxUpdate = (el, oldValue, value, rawValue = getValue(el)) => {
|
|
1356
1364
|
el._modelValue = value;
|
|
1357
1365
|
let checked;
|
|
1358
1366
|
if (shared.isArray(value)) {
|
|
1359
|
-
checked = shared.looseIndexOf(value,
|
|
1367
|
+
checked = shared.looseIndexOf(value, rawValue) > -1;
|
|
1360
1368
|
} else if (shared.isSet(value)) {
|
|
1361
|
-
checked = value.has(
|
|
1369
|
+
checked = value.has(rawValue);
|
|
1362
1370
|
} else {
|
|
1363
1371
|
if (value === oldValue) return;
|
|
1364
1372
|
checked = shared.looseEqual(value, getCheckboxValue(el, true));
|
|
@@ -1366,7 +1374,7 @@ function setChecked(el, { value, oldValue }, vnode) {
|
|
|
1366
1374
|
if (el.checked !== checked) {
|
|
1367
1375
|
el.checked = checked;
|
|
1368
1376
|
}
|
|
1369
|
-
}
|
|
1377
|
+
};
|
|
1370
1378
|
const vModelRadio = {
|
|
1371
1379
|
created(el, { value }, vnode) {
|
|
1372
1380
|
el.checked = shared.looseEqual(value, vnode.props.value);
|
|
@@ -1386,36 +1394,38 @@ const vModelSelect = {
|
|
|
1386
1394
|
// <select multiple> value need to be deep traversed
|
|
1387
1395
|
deep: true,
|
|
1388
1396
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
1389
|
-
|
|
1390
|
-
addEventListener(el, "change", () => {
|
|
1391
|
-
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1392
|
-
(o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
|
|
1393
|
-
);
|
|
1394
|
-
el[assignKey](
|
|
1395
|
-
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1396
|
-
);
|
|
1397
|
-
el._assigning = true;
|
|
1398
|
-
runtimeCore.nextTick(() => {
|
|
1399
|
-
el._assigning = false;
|
|
1400
|
-
});
|
|
1401
|
-
});
|
|
1397
|
+
vModelSelectInit(el, value, number);
|
|
1402
1398
|
el[assignKey] = getModelAssigner(vnode);
|
|
1403
1399
|
},
|
|
1404
1400
|
// set value in mounted & updated because <select> relies on its children
|
|
1405
1401
|
// <option>s.
|
|
1406
1402
|
mounted(el, { value }) {
|
|
1407
|
-
|
|
1403
|
+
vModelSetSelected(el, value);
|
|
1408
1404
|
},
|
|
1409
1405
|
beforeUpdate(el, _binding, vnode) {
|
|
1410
1406
|
el[assignKey] = getModelAssigner(vnode);
|
|
1411
1407
|
},
|
|
1412
1408
|
updated(el, { value }) {
|
|
1413
|
-
|
|
1414
|
-
setSelected(el, value);
|
|
1415
|
-
}
|
|
1409
|
+
vModelSetSelected(el, value);
|
|
1416
1410
|
}
|
|
1417
1411
|
};
|
|
1418
|
-
|
|
1412
|
+
const vModelSelectInit = (el, value, number, set) => {
|
|
1413
|
+
const isSetModel = shared.isSet(value);
|
|
1414
|
+
addEventListener(el, "change", () => {
|
|
1415
|
+
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1416
|
+
(o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
|
|
1417
|
+
);
|
|
1418
|
+
(0, el[assignKey])(
|
|
1419
|
+
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1420
|
+
);
|
|
1421
|
+
el._assigning = true;
|
|
1422
|
+
runtimeCore.nextTick(() => {
|
|
1423
|
+
el._assigning = false;
|
|
1424
|
+
});
|
|
1425
|
+
});
|
|
1426
|
+
};
|
|
1427
|
+
const vModelSetSelected = (el, value) => {
|
|
1428
|
+
if (el._assigning) return;
|
|
1419
1429
|
const isMultiple = el.multiple;
|
|
1420
1430
|
const isArrayValue = shared.isArray(value);
|
|
1421
1431
|
if (isMultiple && !isArrayValue && !shared.isSet(value)) {
|
|
@@ -1443,13 +1453,20 @@ function setSelected(el, value) {
|
|
|
1443
1453
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
1444
1454
|
el.selectedIndex = -1;
|
|
1445
1455
|
}
|
|
1446
|
-
}
|
|
1456
|
+
};
|
|
1447
1457
|
function getValue(el) {
|
|
1448
1458
|
return "_value" in el ? el._value : el.value;
|
|
1449
1459
|
}
|
|
1450
1460
|
function getCheckboxValue(el, checked) {
|
|
1451
1461
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
1452
|
-
|
|
1462
|
+
if (key in el) {
|
|
1463
|
+
return el[key];
|
|
1464
|
+
}
|
|
1465
|
+
const attr = checked ? "true-value" : "false-value";
|
|
1466
|
+
if (el.hasAttribute(attr)) {
|
|
1467
|
+
return el.getAttribute(attr);
|
|
1468
|
+
}
|
|
1469
|
+
return checked;
|
|
1453
1470
|
}
|
|
1454
1471
|
const vModelDynamic = {
|
|
1455
1472
|
created(el, binding, vnode) {
|
package/dist/runtime-dom.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export declare const TransitionGroup: {
|
|
|
42
42
|
declare const vShowOriginalDisplay: unique symbol;
|
|
43
43
|
declare const vShowHidden: unique symbol;
|
|
44
44
|
interface VShowElement extends HTMLElement {
|
|
45
|
-
[vShowOriginalDisplay]
|
|
46
|
-
[vShowHidden]
|
|
45
|
+
[vShowOriginalDisplay]?: string;
|
|
46
|
+
[vShowHidden]?: boolean;
|
|
47
47
|
}
|
|
48
48
|
export declare const vShow: ObjectDirective<VShowElement> & {
|
|
49
49
|
name?: 'show';
|
|
@@ -181,7 +181,7 @@ export declare function useCssModule(name?: string): Record<string, string>;
|
|
|
181
181
|
* Runtime helper for SFC's CSS variable injection feature.
|
|
182
182
|
* @private
|
|
183
183
|
*/
|
|
184
|
-
export declare function useCssVars(getter: (ctx: any) => Record<string,
|
|
184
|
+
export declare function useCssVars(getter: (ctx: any) => Record<string, unknown>): void;
|
|
185
185
|
|
|
186
186
|
export interface CSSProperties extends CSS.Properties<string | number>, CSS.PropertiesHyphen<string | number> {
|
|
187
187
|
/**
|
|
@@ -1385,13 +1385,13 @@ declare module '@vue/runtime-core' {
|
|
|
1385
1385
|
vOn: VOnDirective;
|
|
1386
1386
|
vBind: VModelDirective;
|
|
1387
1387
|
vIf: Directive<any, boolean>;
|
|
1388
|
-
|
|
1389
|
-
|
|
1388
|
+
vOnce: Directive;
|
|
1389
|
+
vSlot: Directive;
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
1392
|
export declare const render: RootRenderFunction<Element | ShadowRoot>;
|
|
1393
1393
|
export declare const hydrate: RootHydrateFunction;
|
|
1394
|
-
export declare const createApp: CreateAppFunction<Element>;
|
|
1394
|
+
export declare const createApp: CreateAppFunction<Element, Component>;
|
|
1395
1395
|
export declare const createSSRApp: CreateAppFunction<Element>;
|
|
1396
1396
|
|
|
1397
1397
|
|