@vue/runtime-dom 3.4.0-alpha.4 → 3.4.0-beta.2

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);
@@ -621,7 +622,8 @@ function patchStopImmediatePropagation(e, value) {
621
622
 
622
623
  const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
623
624
  key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
624
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
625
+ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
626
+ const isSVG = namespace === "svg";
625
627
  if (key === "class") {
626
628
  patchClass(el, nextValue, isSVG);
627
629
  } else if (key === "style") {
@@ -673,7 +675,9 @@ function shouldSetAsProp(el, key, value, isSVG) {
673
675
  }
674
676
  if (key === "width" || key === "height") {
675
677
  const tag = el.tagName;
676
- return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
678
+ if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
679
+ return false;
680
+ }
677
681
  }
678
682
  if (isNativeOn(key) && shared.isString(value)) {
679
683
  return false;
@@ -1398,7 +1402,7 @@ const createApp = (...args) => {
1398
1402
  component.template = container.innerHTML;
1399
1403
  }
1400
1404
  container.innerHTML = "";
1401
- const proxy = mount(container, false, container instanceof SVGElement);
1405
+ const proxy = mount(container, false, resolveRootNamespace(container));
1402
1406
  if (container instanceof Element) {
1403
1407
  container.removeAttribute("v-cloak");
1404
1408
  container.setAttribute("data-v-app", "");
@@ -1417,14 +1421,22 @@ const createSSRApp = (...args) => {
1417
1421
  app.mount = (containerOrSelector) => {
1418
1422
  const container = normalizeContainer(containerOrSelector);
1419
1423
  if (container) {
1420
- return mount(container, true, container instanceof SVGElement);
1424
+ return mount(container, true, resolveRootNamespace(container));
1421
1425
  }
1422
1426
  };
1423
1427
  return app;
1424
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
+ }
1425
1437
  function injectNativeTagCheck(app) {
1426
1438
  Object.defineProperty(app.config, "isNativeTag", {
1427
- value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
1439
+ value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
1428
1440
  writable: false
1429
1441
  });
1430
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);
@@ -604,7 +605,8 @@ function patchStopImmediatePropagation(e, value) {
604
605
 
605
606
  const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
606
607
  key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
607
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
608
+ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
609
+ const isSVG = namespace === "svg";
608
610
  if (key === "class") {
609
611
  patchClass(el, nextValue, isSVG);
610
612
  } else if (key === "style") {
@@ -656,7 +658,9 @@ function shouldSetAsProp(el, key, value, isSVG) {
656
658
  }
657
659
  if (key === "width" || key === "height") {
658
660
  const tag = el.tagName;
659
- return !(tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE");
661
+ if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
662
+ return false;
663
+ }
660
664
  }
661
665
  if (isNativeOn(key) && shared.isString(value)) {
662
666
  return false;
@@ -1350,7 +1354,7 @@ const createApp = (...args) => {
1350
1354
  component.template = container.innerHTML;
1351
1355
  }
1352
1356
  container.innerHTML = "";
1353
- const proxy = mount(container, false, container instanceof SVGElement);
1357
+ const proxy = mount(container, false, resolveRootNamespace(container));
1354
1358
  if (container instanceof Element) {
1355
1359
  container.removeAttribute("v-cloak");
1356
1360
  container.setAttribute("data-v-app", "");
@@ -1365,11 +1369,19 @@ const createSSRApp = (...args) => {
1365
1369
  app.mount = (containerOrSelector) => {
1366
1370
  const container = normalizeContainer(containerOrSelector);
1367
1371
  if (container) {
1368
- return mount(container, true, container instanceof SVGElement);
1372
+ return mount(container, true, resolveRootNamespace(container));
1369
1373
  }
1370
1374
  };
1371
1375
  return app;
1372
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
+ }
1373
1385
  function normalizeContainer(container) {
1374
1386
  if (shared.isString(container)) {
1375
1387
  const res = document.querySelector(container);
@@ -131,7 +131,7 @@ export interface CSSProperties extends CSS.Properties<string | number>, CSS.Prop
131
131
  }
132
132
  type Booleanish = boolean | 'true' | 'false';
133
133
  type Numberish = number | string;
134
- interface AriaAttributes {
134
+ export interface AriaAttributes {
135
135
  /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
136
136
  'aria-activedescendant'?: string;
137
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. */
@@ -1012,6 +1012,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers<Events> {
1012
1012
  xlinkTitle?: string;
1013
1013
  xlinkType?: string;
1014
1014
  xmlns?: string;
1015
+ xmlnsXlink?: string;
1015
1016
  y1?: Numberish;
1016
1017
  y2?: Numberish;
1017
1018
  y?: Numberish;