@vue/runtime-dom 3.4.0-alpha.3 → 3.4.0-beta.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.
@@ -6,6 +6,7 @@ var runtimeCore = require('@vue/runtime-core');
6
6
  var shared = require('@vue/shared');
7
7
 
8
8
  const svgNS = "http://www.w3.org/2000/svg";
9
+ const mathmlNS = "http://www.w3.org/1998/Math/MathML";
9
10
  const doc = typeof document !== "undefined" ? document : null;
10
11
  const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
11
12
  const nodeOps = {
@@ -18,8 +19,8 @@ const nodeOps = {
18
19
  parent.removeChild(child);
19
20
  }
20
21
  },
21
- createElement: (tag, isSVG, is, props) => {
22
- const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
22
+ createElement: (tag, namespace, is, props) => {
23
+ const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
23
24
  if (tag === "select" && props && props.multiple != null) {
24
25
  el.setAttribute("multiple", props.multiple);
25
26
  }
@@ -43,7 +44,7 @@ const nodeOps = {
43
44
  // Reason: innerHTML.
44
45
  // Static content here can only come from compiled templates.
45
46
  // As long as the user only uses trusted templates, this is safe.
46
- insertStaticContent(content, parent, anchor, isSVG, start, end) {
47
+ insertStaticContent(content, parent, anchor, namespace, start, end) {
47
48
  const before = anchor ? anchor.previousSibling : parent.lastChild;
48
49
  if (start && (start === end || start.nextSibling)) {
49
50
  while (true) {
@@ -52,9 +53,9 @@ const nodeOps = {
52
53
  break;
53
54
  }
54
55
  } else {
55
- templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
56
+ templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
56
57
  const template = templateContainer.content;
57
- if (isSVG) {
58
+ if (namespace === "svg" || namespace === "mathml") {
58
59
  const wrapper = template.firstChild;
59
60
  while (wrapper.firstChild) {
60
61
  template.appendChild(wrapper.firstChild);
@@ -619,8 +620,10 @@ function patchStopImmediatePropagation(e, value) {
619
620
  }
620
621
  }
621
622
 
622
- const nativeOnRE = /^on[a-z]/;
623
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
623
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
624
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
625
+ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
626
+ const isSVG = namespace === "svg";
624
627
  if (key === "class") {
625
628
  patchClass(el, nextValue, isSVG);
626
629
  } else if (key === "style") {
@@ -653,7 +656,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
653
656
  if (key === "innerHTML" || key === "textContent") {
654
657
  return true;
655
658
  }
656
- if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) {
659
+ if (key in el && isNativeOn(key) && shared.isFunction(value)) {
657
660
  return true;
658
661
  }
659
662
  return false;
@@ -670,7 +673,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
670
673
  if (key === "type" && el.tagName === "TEXTAREA") {
671
674
  return false;
672
675
  }
673
- if (nativeOnRE.test(key) && shared.isString(value)) {
676
+ if (key === "width" || key === "height") {
677
+ const tag = el.tagName;
678
+ if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
679
+ return false;
680
+ }
681
+ }
682
+ if (isNativeOn(key) && shared.isString(value)) {
674
683
  return false;
675
684
  }
676
685
  return key in el;
@@ -1330,14 +1339,14 @@ const modifierGuards = {
1330
1339
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1331
1340
  };
1332
1341
  const withModifiers = (fn, modifiers) => {
1333
- return (event, ...args) => {
1342
+ return fn._withMods || (fn._withMods = (event, ...args) => {
1334
1343
  for (let i = 0; i < modifiers.length; i++) {
1335
1344
  const guard = modifierGuards[modifiers[i]];
1336
1345
  if (guard && guard(event, modifiers))
1337
1346
  return;
1338
1347
  }
1339
1348
  return fn(event, ...args);
1340
- };
1349
+ });
1341
1350
  };
1342
1351
  const keyNames = {
1343
1352
  esc: "escape",
@@ -1349,7 +1358,7 @@ const keyNames = {
1349
1358
  delete: "backspace"
1350
1359
  };
1351
1360
  const withKeys = (fn, modifiers) => {
1352
- return (event) => {
1361
+ return fn._withKeys || (fn._withKeys = (event) => {
1353
1362
  if (!("key" in event)) {
1354
1363
  return;
1355
1364
  }
@@ -1357,7 +1366,7 @@ const withKeys = (fn, modifiers) => {
1357
1366
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
1358
1367
  return fn(event);
1359
1368
  }
1360
- };
1369
+ });
1361
1370
  };
1362
1371
 
1363
1372
  const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
@@ -1393,7 +1402,7 @@ const createApp = (...args) => {
1393
1402
  component.template = container.innerHTML;
1394
1403
  }
1395
1404
  container.innerHTML = "";
1396
- const proxy = mount(container, false, container instanceof SVGElement);
1405
+ const proxy = mount(container, false, resolveRootNamespace(container));
1397
1406
  if (container instanceof Element) {
1398
1407
  container.removeAttribute("v-cloak");
1399
1408
  container.setAttribute("data-v-app", "");
@@ -1412,14 +1421,22 @@ const createSSRApp = (...args) => {
1412
1421
  app.mount = (containerOrSelector) => {
1413
1422
  const container = normalizeContainer(containerOrSelector);
1414
1423
  if (container) {
1415
- return mount(container, true, container instanceof SVGElement);
1424
+ return mount(container, true, resolveRootNamespace(container));
1416
1425
  }
1417
1426
  };
1418
1427
  return app;
1419
1428
  };
1429
+ function resolveRootNamespace(container) {
1430
+ if (container instanceof SVGElement) {
1431
+ return "svg";
1432
+ }
1433
+ if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
1434
+ return "mathml";
1435
+ }
1436
+ }
1420
1437
  function injectNativeTagCheck(app) {
1421
1438
  Object.defineProperty(app.config, "isNativeTag", {
1422
- value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
1439
+ value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
1423
1440
  writable: false
1424
1441
  });
1425
1442
  }
@@ -6,6 +6,7 @@ var runtimeCore = require('@vue/runtime-core');
6
6
  var shared = require('@vue/shared');
7
7
 
8
8
  const svgNS = "http://www.w3.org/2000/svg";
9
+ const mathmlNS = "http://www.w3.org/1998/Math/MathML";
9
10
  const doc = typeof document !== "undefined" ? document : null;
10
11
  const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
11
12
  const nodeOps = {
@@ -18,8 +19,8 @@ const nodeOps = {
18
19
  parent.removeChild(child);
19
20
  }
20
21
  },
21
- createElement: (tag, isSVG, is, props) => {
22
- const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
22
+ createElement: (tag, namespace, is, props) => {
23
+ const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
23
24
  if (tag === "select" && props && props.multiple != null) {
24
25
  el.setAttribute("multiple", props.multiple);
25
26
  }
@@ -43,7 +44,7 @@ const nodeOps = {
43
44
  // Reason: innerHTML.
44
45
  // Static content here can only come from compiled templates.
45
46
  // As long as the user only uses trusted templates, this is safe.
46
- insertStaticContent(content, parent, anchor, isSVG, start, end) {
47
+ insertStaticContent(content, parent, anchor, namespace, start, end) {
47
48
  const before = anchor ? anchor.previousSibling : parent.lastChild;
48
49
  if (start && (start === end || start.nextSibling)) {
49
50
  while (true) {
@@ -52,9 +53,9 @@ const nodeOps = {
52
53
  break;
53
54
  }
54
55
  } else {
55
- templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
56
+ templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
56
57
  const template = templateContainer.content;
57
- if (isSVG) {
58
+ if (namespace === "svg" || namespace === "mathml") {
58
59
  const wrapper = template.firstChild;
59
60
  while (wrapper.firstChild) {
60
61
  template.appendChild(wrapper.firstChild);
@@ -602,8 +603,10 @@ function patchStopImmediatePropagation(e, value) {
602
603
  }
603
604
  }
604
605
 
605
- const nativeOnRE = /^on[a-z]/;
606
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
606
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
607
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
608
+ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
609
+ const isSVG = namespace === "svg";
607
610
  if (key === "class") {
608
611
  patchClass(el, nextValue, isSVG);
609
612
  } else if (key === "style") {
@@ -636,7 +639,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
636
639
  if (key === "innerHTML" || key === "textContent") {
637
640
  return true;
638
641
  }
639
- if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) {
642
+ if (key in el && isNativeOn(key) && shared.isFunction(value)) {
640
643
  return true;
641
644
  }
642
645
  return false;
@@ -653,7 +656,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
653
656
  if (key === "type" && el.tagName === "TEXTAREA") {
654
657
  return false;
655
658
  }
656
- if (nativeOnRE.test(key) && shared.isString(value)) {
659
+ if (key === "width" || key === "height") {
660
+ const tag = el.tagName;
661
+ if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
662
+ return false;
663
+ }
664
+ }
665
+ if (isNativeOn(key) && shared.isString(value)) {
657
666
  return false;
658
667
  }
659
668
  return key in el;
@@ -1286,14 +1295,14 @@ const modifierGuards = {
1286
1295
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1287
1296
  };
1288
1297
  const withModifiers = (fn, modifiers) => {
1289
- return (event, ...args) => {
1298
+ return fn._withMods || (fn._withMods = (event, ...args) => {
1290
1299
  for (let i = 0; i < modifiers.length; i++) {
1291
1300
  const guard = modifierGuards[modifiers[i]];
1292
1301
  if (guard && guard(event, modifiers))
1293
1302
  return;
1294
1303
  }
1295
1304
  return fn(event, ...args);
1296
- };
1305
+ });
1297
1306
  };
1298
1307
  const keyNames = {
1299
1308
  esc: "escape",
@@ -1305,7 +1314,7 @@ const keyNames = {
1305
1314
  delete: "backspace"
1306
1315
  };
1307
1316
  const withKeys = (fn, modifiers) => {
1308
- return (event) => {
1317
+ return fn._withKeys || (fn._withKeys = (event) => {
1309
1318
  if (!("key" in event)) {
1310
1319
  return;
1311
1320
  }
@@ -1313,7 +1322,7 @@ const withKeys = (fn, modifiers) => {
1313
1322
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
1314
1323
  return fn(event);
1315
1324
  }
1316
- };
1325
+ });
1317
1326
  };
1318
1327
 
1319
1328
  const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
@@ -1345,7 +1354,7 @@ const createApp = (...args) => {
1345
1354
  component.template = container.innerHTML;
1346
1355
  }
1347
1356
  container.innerHTML = "";
1348
- const proxy = mount(container, false, container instanceof SVGElement);
1357
+ const proxy = mount(container, false, resolveRootNamespace(container));
1349
1358
  if (container instanceof Element) {
1350
1359
  container.removeAttribute("v-cloak");
1351
1360
  container.setAttribute("data-v-app", "");
@@ -1360,11 +1369,19 @@ const createSSRApp = (...args) => {
1360
1369
  app.mount = (containerOrSelector) => {
1361
1370
  const container = normalizeContainer(containerOrSelector);
1362
1371
  if (container) {
1363
- return mount(container, true, container instanceof SVGElement);
1372
+ return mount(container, true, resolveRootNamespace(container));
1364
1373
  }
1365
1374
  };
1366
1375
  return app;
1367
1376
  };
1377
+ function resolveRootNamespace(container) {
1378
+ if (container instanceof SVGElement) {
1379
+ return "svg";
1380
+ }
1381
+ if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
1382
+ return "mathml";
1383
+ }
1384
+ }
1368
1385
  function normalizeContainer(container) {
1369
1386
  if (shared.isString(container)) {
1370
1387
  const res = document.querySelector(container);
@@ -102,11 +102,15 @@ export declare const vModelDynamic: ObjectDirective<HTMLInputElement | HTMLSelec
102
102
  /**
103
103
  * @private
104
104
  */
105
- export declare const withModifiers: (fn: Function, modifiers: string[]) => (event: Event, ...args: unknown[]) => any;
105
+ export declare const withModifiers: <T extends (event: Event, ...args: unknown[]) => any>(fn: T & {
106
+ _withMods?: T | undefined;
107
+ }, modifiers: string[]) => T;
106
108
  /**
107
109
  * @private
108
110
  */
109
- export declare const withKeys: (fn: Function, modifiers: string[]) => (event: KeyboardEvent) => any;
111
+ export declare const withKeys: <T extends (event: KeyboardEvent) => any>(fn: T & {
112
+ _withKeys?: T | undefined;
113
+ }, modifiers: string[]) => T;
110
114
 
111
115
  declare const vShowOldKey: unique symbol;
112
116
  interface VShowElement extends HTMLElement {
@@ -127,7 +131,7 @@ export interface CSSProperties extends CSS.Properties<string | number>, CSS.Prop
127
131
  }
128
132
  type Booleanish = boolean | 'true' | 'false';
129
133
  type Numberish = number | string;
130
- interface AriaAttributes {
134
+ export interface AriaAttributes {
131
135
  /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
132
136
  'aria-activedescendant'?: string;
133
137
  /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
@@ -1008,6 +1012,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers<Events> {
1008
1012
  xlinkTitle?: string;
1009
1013
  xlinkType?: string;
1010
1014
  xmlns?: string;
1015
+ xmlnsXlink?: string;
1011
1016
  y1?: Numberish;
1012
1017
  y2?: Numberish;
1013
1018
  y?: Numberish;