@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,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;
|
|
@@ -1267,28 +1249,12 @@ const assignKey = Symbol("_assign");
|
|
|
1267
1249
|
const vModelText = {
|
|
1268
1250
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
|
1269
1251
|
el[assignKey] = getModelAssigner(vnode);
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
}
|
|
1277
|
-
if (castToNumber) {
|
|
1278
|
-
domValue = shared.looseToNumber(domValue);
|
|
1279
|
-
}
|
|
1280
|
-
el[assignKey](domValue);
|
|
1281
|
-
});
|
|
1282
|
-
if (trim) {
|
|
1283
|
-
addEventListener(el, "change", () => {
|
|
1284
|
-
el.value = el.value.trim();
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
if (!lazy) {
|
|
1288
|
-
addEventListener(el, "compositionstart", onCompositionStart);
|
|
1289
|
-
addEventListener(el, "compositionend", onCompositionEnd);
|
|
1290
|
-
addEventListener(el, "change", onCompositionEnd);
|
|
1291
|
-
}
|
|
1252
|
+
vModelTextInit(
|
|
1253
|
+
el,
|
|
1254
|
+
trim,
|
|
1255
|
+
number || !!(vnode.props && vnode.props.type === "number"),
|
|
1256
|
+
lazy
|
|
1257
|
+
);
|
|
1292
1258
|
},
|
|
1293
1259
|
// set value on mounted so it's after min/max for type="range"
|
|
1294
1260
|
mounted(el, { value }) {
|
|
@@ -1296,70 +1262,111 @@ const vModelText = {
|
|
|
1296
1262
|
},
|
|
1297
1263
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
|
|
1298
1264
|
el[assignKey] = getModelAssigner(vnode);
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
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) {
|
|
1303
1300
|
return;
|
|
1304
1301
|
}
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
if (trim && el.value.trim() === newValue) {
|
|
1310
|
-
return;
|
|
1311
|
-
}
|
|
1302
|
+
if (trim && el.value.trim() === newValue) {
|
|
1303
|
+
return;
|
|
1312
1304
|
}
|
|
1313
|
-
el.value = newValue;
|
|
1314
1305
|
}
|
|
1306
|
+
el.value = newValue;
|
|
1315
1307
|
};
|
|
1316
1308
|
const vModelCheckbox = {
|
|
1317
1309
|
// #4096 array checkboxes need to be deep traversed
|
|
1318
1310
|
deep: true,
|
|
1319
1311
|
created(el, _, vnode) {
|
|
1320
1312
|
el[assignKey] = getModelAssigner(vnode);
|
|
1321
|
-
|
|
1322
|
-
const modelValue = el._modelValue;
|
|
1323
|
-
const elementValue = getValue(el);
|
|
1324
|
-
const checked = el.checked;
|
|
1325
|
-
const assign = el[assignKey];
|
|
1326
|
-
if (shared.isArray(modelValue)) {
|
|
1327
|
-
const index = shared.looseIndexOf(modelValue, elementValue);
|
|
1328
|
-
const found = index !== -1;
|
|
1329
|
-
if (checked && !found) {
|
|
1330
|
-
assign(modelValue.concat(elementValue));
|
|
1331
|
-
} else if (!checked && found) {
|
|
1332
|
-
const filtered = [...modelValue];
|
|
1333
|
-
filtered.splice(index, 1);
|
|
1334
|
-
assign(filtered);
|
|
1335
|
-
}
|
|
1336
|
-
} else if (shared.isSet(modelValue)) {
|
|
1337
|
-
const cloned = new Set(modelValue);
|
|
1338
|
-
if (checked) {
|
|
1339
|
-
cloned.add(elementValue);
|
|
1340
|
-
} else {
|
|
1341
|
-
cloned.delete(elementValue);
|
|
1342
|
-
}
|
|
1343
|
-
assign(cloned);
|
|
1344
|
-
} else {
|
|
1345
|
-
assign(getCheckboxValue(el, checked));
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
1313
|
+
vModelCheckboxInit(el);
|
|
1348
1314
|
},
|
|
1349
1315
|
// set initial checked on mount to wait for true-value/false-value
|
|
1350
|
-
mounted
|
|
1316
|
+
mounted(el, binding, vnode) {
|
|
1317
|
+
vModelCheckboxUpdate(
|
|
1318
|
+
el,
|
|
1319
|
+
binding.oldValue,
|
|
1320
|
+
binding.value,
|
|
1321
|
+
vnode.props.value
|
|
1322
|
+
);
|
|
1323
|
+
},
|
|
1351
1324
|
beforeUpdate(el, binding, vnode) {
|
|
1352
1325
|
el[assignKey] = getModelAssigner(vnode);
|
|
1353
|
-
|
|
1326
|
+
vModelCheckboxUpdate(
|
|
1327
|
+
el,
|
|
1328
|
+
binding.oldValue,
|
|
1329
|
+
binding.value,
|
|
1330
|
+
vnode.props.value
|
|
1331
|
+
);
|
|
1354
1332
|
}
|
|
1355
1333
|
};
|
|
1356
|
-
|
|
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)) => {
|
|
1357
1364
|
el._modelValue = value;
|
|
1358
1365
|
let checked;
|
|
1359
1366
|
if (shared.isArray(value)) {
|
|
1360
|
-
checked = shared.looseIndexOf(value,
|
|
1367
|
+
checked = shared.looseIndexOf(value, rawValue) > -1;
|
|
1361
1368
|
} else if (shared.isSet(value)) {
|
|
1362
|
-
checked = value.has(
|
|
1369
|
+
checked = value.has(rawValue);
|
|
1363
1370
|
} else {
|
|
1364
1371
|
if (value === oldValue) return;
|
|
1365
1372
|
checked = shared.looseEqual(value, getCheckboxValue(el, true));
|
|
@@ -1367,7 +1374,7 @@ function setChecked(el, { value, oldValue }, vnode) {
|
|
|
1367
1374
|
if (el.checked !== checked) {
|
|
1368
1375
|
el.checked = checked;
|
|
1369
1376
|
}
|
|
1370
|
-
}
|
|
1377
|
+
};
|
|
1371
1378
|
const vModelRadio = {
|
|
1372
1379
|
created(el, { value }, vnode) {
|
|
1373
1380
|
el.checked = shared.looseEqual(value, vnode.props.value);
|
|
@@ -1387,36 +1394,38 @@ const vModelSelect = {
|
|
|
1387
1394
|
// <select multiple> value need to be deep traversed
|
|
1388
1395
|
deep: true,
|
|
1389
1396
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
1390
|
-
|
|
1391
|
-
addEventListener(el, "change", () => {
|
|
1392
|
-
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
1393
|
-
(o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
|
|
1394
|
-
);
|
|
1395
|
-
el[assignKey](
|
|
1396
|
-
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
1397
|
-
);
|
|
1398
|
-
el._assigning = true;
|
|
1399
|
-
runtimeCore.nextTick(() => {
|
|
1400
|
-
el._assigning = false;
|
|
1401
|
-
});
|
|
1402
|
-
});
|
|
1397
|
+
vModelSelectInit(el, value, number);
|
|
1403
1398
|
el[assignKey] = getModelAssigner(vnode);
|
|
1404
1399
|
},
|
|
1405
1400
|
// set value in mounted & updated because <select> relies on its children
|
|
1406
1401
|
// <option>s.
|
|
1407
1402
|
mounted(el, { value }) {
|
|
1408
|
-
|
|
1403
|
+
vModelSetSelected(el, value);
|
|
1409
1404
|
},
|
|
1410
1405
|
beforeUpdate(el, _binding, vnode) {
|
|
1411
1406
|
el[assignKey] = getModelAssigner(vnode);
|
|
1412
1407
|
},
|
|
1413
1408
|
updated(el, { value }) {
|
|
1414
|
-
|
|
1415
|
-
setSelected(el, value);
|
|
1416
|
-
}
|
|
1409
|
+
vModelSetSelected(el, value);
|
|
1417
1410
|
}
|
|
1418
1411
|
};
|
|
1419
|
-
|
|
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;
|
|
1420
1429
|
const isMultiple = el.multiple;
|
|
1421
1430
|
const isArrayValue = shared.isArray(value);
|
|
1422
1431
|
if (isMultiple && !isArrayValue && !shared.isSet(value)) {
|
|
@@ -1444,13 +1453,20 @@ function setSelected(el, value) {
|
|
|
1444
1453
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
1445
1454
|
el.selectedIndex = -1;
|
|
1446
1455
|
}
|
|
1447
|
-
}
|
|
1456
|
+
};
|
|
1448
1457
|
function getValue(el) {
|
|
1449
1458
|
return "_value" in el ? el._value : el.value;
|
|
1450
1459
|
}
|
|
1451
1460
|
function getCheckboxValue(el, checked) {
|
|
1452
1461
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
1453
|
-
|
|
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;
|
|
1454
1470
|
}
|
|
1455
1471
|
const vModelDynamic = {
|
|
1456
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
|
/**
|
|
@@ -1391,7 +1391,7 @@ declare module '@vue/runtime-core' {
|
|
|
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
|
|