@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.
@@ -1,8 +1,9 @@
1
1
  import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
2
2
  export * from '@vue/runtime-core';
3
- import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag } from '@vue/shared';
3
+ import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
4
4
 
5
5
  const svgNS = "http://www.w3.org/2000/svg";
6
+ const mathmlNS = "http://www.w3.org/1998/Math/MathML";
6
7
  const doc = typeof document !== "undefined" ? document : null;
7
8
  const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
8
9
  const nodeOps = {
@@ -15,8 +16,8 @@ const nodeOps = {
15
16
  parent.removeChild(child);
16
17
  }
17
18
  },
18
- createElement: (tag, isSVG, is, props) => {
19
- const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
19
+ createElement: (tag, namespace, is, props) => {
20
+ const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0);
20
21
  if (tag === "select" && props && props.multiple != null) {
21
22
  el.setAttribute("multiple", props.multiple);
22
23
  }
@@ -40,7 +41,7 @@ const nodeOps = {
40
41
  // Reason: innerHTML.
41
42
  // Static content here can only come from compiled templates.
42
43
  // As long as the user only uses trusted templates, this is safe.
43
- insertStaticContent(content, parent, anchor, isSVG, start, end) {
44
+ insertStaticContent(content, parent, anchor, namespace, start, end) {
44
45
  const before = anchor ? anchor.previousSibling : parent.lastChild;
45
46
  if (start && (start === end || start.nextSibling)) {
46
47
  while (true) {
@@ -49,9 +50,9 @@ const nodeOps = {
49
50
  break;
50
51
  }
51
52
  } else {
52
- templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
53
+ templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
53
54
  const template = templateContainer.content;
54
- if (isSVG) {
55
+ if (namespace === "svg" || namespace === "mathml") {
55
56
  const wrapper = template.firstChild;
56
57
  while (wrapper.firstChild) {
57
58
  template.appendChild(wrapper.firstChild);
@@ -616,8 +617,10 @@ function patchStopImmediatePropagation(e, value) {
616
617
  }
617
618
  }
618
619
 
619
- const nativeOnRE = /^on[a-z]/;
620
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
620
+ const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
621
+ key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
622
+ const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
623
+ const isSVG = namespace === "svg";
621
624
  if (key === "class") {
622
625
  patchClass(el, nextValue, isSVG);
623
626
  } else if (key === "style") {
@@ -650,7 +653,7 @@ function shouldSetAsProp(el, key, value, isSVG) {
650
653
  if (key === "innerHTML" || key === "textContent") {
651
654
  return true;
652
655
  }
653
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
656
+ if (key in el && isNativeOn(key) && isFunction(value)) {
654
657
  return true;
655
658
  }
656
659
  return false;
@@ -667,7 +670,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
667
670
  if (key === "type" && el.tagName === "TEXTAREA") {
668
671
  return false;
669
672
  }
670
- if (nativeOnRE.test(key) && isString(value)) {
673
+ if (key === "width" || key === "height") {
674
+ const tag = el.tagName;
675
+ if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
676
+ return false;
677
+ }
678
+ }
679
+ if (isNativeOn(key) && isString(value)) {
671
680
  return false;
672
681
  }
673
682
  return key in el;
@@ -1382,14 +1391,14 @@ const modifierGuards = {
1382
1391
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1383
1392
  };
1384
1393
  const withModifiers = (fn, modifiers) => {
1385
- return (event, ...args) => {
1394
+ return fn._withMods || (fn._withMods = (event, ...args) => {
1386
1395
  for (let i = 0; i < modifiers.length; i++) {
1387
1396
  const guard = modifierGuards[modifiers[i]];
1388
1397
  if (guard && guard(event, modifiers))
1389
1398
  return;
1390
1399
  }
1391
1400
  return fn(event, ...args);
1392
- };
1401
+ });
1393
1402
  };
1394
1403
  const keyNames = {
1395
1404
  esc: "escape",
@@ -1401,7 +1410,7 @@ const keyNames = {
1401
1410
  delete: "backspace"
1402
1411
  };
1403
1412
  const withKeys = (fn, modifiers) => {
1404
- return (event) => {
1413
+ return fn._withKeys || (fn._withKeys = (event) => {
1405
1414
  if (!("key" in event)) {
1406
1415
  return;
1407
1416
  }
@@ -1409,7 +1418,7 @@ const withKeys = (fn, modifiers) => {
1409
1418
  if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
1410
1419
  return fn(event);
1411
1420
  }
1412
- };
1421
+ });
1413
1422
  };
1414
1423
 
1415
1424
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
@@ -1445,7 +1454,7 @@ const createApp = (...args) => {
1445
1454
  component.template = container.innerHTML;
1446
1455
  }
1447
1456
  container.innerHTML = "";
1448
- const proxy = mount(container, false, container instanceof SVGElement);
1457
+ const proxy = mount(container, false, resolveRootNamespace(container));
1449
1458
  if (container instanceof Element) {
1450
1459
  container.removeAttribute("v-cloak");
1451
1460
  container.setAttribute("data-v-app", "");
@@ -1464,14 +1473,22 @@ const createSSRApp = (...args) => {
1464
1473
  app.mount = (containerOrSelector) => {
1465
1474
  const container = normalizeContainer(containerOrSelector);
1466
1475
  if (container) {
1467
- return mount(container, true, container instanceof SVGElement);
1476
+ return mount(container, true, resolveRootNamespace(container));
1468
1477
  }
1469
1478
  };
1470
1479
  return app;
1471
1480
  };
1481
+ function resolveRootNamespace(container) {
1482
+ if (container instanceof SVGElement) {
1483
+ return "svg";
1484
+ }
1485
+ if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
1486
+ return "mathml";
1487
+ }
1488
+ }
1472
1489
  function injectNativeTagCheck(app) {
1473
1490
  Object.defineProperty(app.config, "isNativeTag", {
1474
- value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
1491
+ value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
1475
1492
  writable: false
1476
1493
  });
1477
1494
  }