@vue/compiler-dom 3.6.0-alpha.3 → 3.6.0-alpha.5

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,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.3
2
+ * @vue/compiler-dom v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -52,6 +52,9 @@ var VueCompilerDOM = (function (exports) {
52
52
  return s;
53
53
  }
54
54
  );
55
+ const getModifierPropName = (name) => {
56
+ return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
57
+ };
55
58
 
56
59
  const PatchFlagNames = {
57
60
  [1]: `TEXT`,
@@ -263,14 +266,6 @@ var VueCompilerDOM = (function (exports) {
263
266
  });
264
267
  }
265
268
 
266
- const Namespaces = {
267
- "HTML": 0,
268
- "0": "HTML",
269
- "SVG": 1,
270
- "1": "SVG",
271
- "MATH_ML": 2,
272
- "2": "MATH_ML"
273
- };
274
269
  const NodeTypes = {
275
270
  "ROOT": 0,
276
271
  "0": "ROOT",
@@ -2109,7 +2104,43 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
2109
2104
  return node;
2110
2105
  }
2111
2106
  }
2107
+ function filterNonCommentChildren(node) {
2108
+ return node.children.filter((n) => n.type !== 3);
2109
+ }
2110
+ function hasSingleChild(node) {
2111
+ return filterNonCommentChildren(node).length === 1;
2112
+ }
2113
+ function isSingleIfBlock(parent) {
2114
+ let hasEncounteredIf = false;
2115
+ for (const c of filterNonCommentChildren(parent)) {
2116
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2117
+ if (hasEncounteredIf) return false;
2118
+ hasEncounteredIf = true;
2119
+ } else if (
2120
+ // node before v-if
2121
+ !hasEncounteredIf || // non else nodes
2122
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2123
+ ) {
2124
+ return false;
2125
+ }
2126
+ }
2127
+ return true;
2128
+ }
2112
2129
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2130
+ function isAllWhitespace(str) {
2131
+ for (let i = 0; i < str.length; i++) {
2132
+ if (!isWhitespace(str.charCodeAt(i))) {
2133
+ return false;
2134
+ }
2135
+ }
2136
+ return true;
2137
+ }
2138
+ function isWhitespaceText(node) {
2139
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2140
+ }
2141
+ function isCommentOrWhitespace(node) {
2142
+ return node.type === 3 || isWhitespaceText(node);
2143
+ }
2113
2144
 
2114
2145
  const defaultParserOptions = {
2115
2146
  parseMode: "base",
@@ -2732,14 +2763,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
2732
2763
  }
2733
2764
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2734
2765
  }
2735
- function isAllWhitespace(str) {
2736
- for (let i = 0; i < str.length; i++) {
2737
- if (!isWhitespace(str.charCodeAt(i))) {
2738
- return false;
2739
- }
2740
- }
2741
- return true;
2742
- }
2743
2766
  function hasNewlineChar(str) {
2744
2767
  for (let i = 0; i < str.length; i++) {
2745
2768
  const c = str.charCodeAt(i);
@@ -4183,13 +4206,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4183
4206
  let i = siblings.indexOf(node);
4184
4207
  while (i-- >= -1) {
4185
4208
  const sibling = siblings[i];
4186
- if (sibling && sibling.type === 3) {
4187
- context.removeNode(sibling);
4188
- comments.unshift(sibling);
4189
- continue;
4190
- }
4191
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4209
+ if (sibling && isCommentOrWhitespace(sibling)) {
4192
4210
  context.removeNode(sibling);
4211
+ if (sibling.type === 3) {
4212
+ comments.unshift(sibling);
4213
+ }
4193
4214
  continue;
4194
4215
  }
4195
4216
  if (sibling && sibling.type === 9) {
@@ -4661,7 +4682,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4661
4682
  let prev;
4662
4683
  while (j--) {
4663
4684
  prev = children[j];
4664
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
4685
+ if (!isCommentOrWhitespace(prev)) {
4665
4686
  break;
4666
4687
  }
4667
4688
  }
@@ -4739,7 +4760,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4739
4760
  } else if (implicitDefaultChildren.length && // #3766
4740
4761
  // with whitespace: 'preserve', whitespaces between slots will end up in
4741
4762
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
4742
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
4763
+ !implicitDefaultChildren.every(isWhitespaceText)) {
4743
4764
  if (hasNamedDefaultSlot) {
4744
4765
  context.onError(
4745
4766
  createCompilerError(
@@ -4812,11 +4833,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4812
4833
  }
4813
4834
  return false;
4814
4835
  }
4815
- function isNonWhitespaceContent(node) {
4816
- if (node.type !== 2 && node.type !== 12)
4817
- return true;
4818
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
4819
- }
4820
4836
 
4821
4837
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
4822
4838
  const transformElement = (node, context) => {
@@ -5713,7 +5729,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
5713
5729
  ];
5714
5730
  if (dir.modifiers.length && node.tagType === 1) {
5715
5731
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
5716
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5732
+ const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5717
5733
  props.push(
5718
5734
  createObjectProperty(
5719
5735
  modifiersKey,
@@ -6079,7 +6095,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6079
6095
  let ns = parent ? parent.ns : rootNamespace;
6080
6096
  if (parent && ns === 2) {
6081
6097
  if (parent.tag === "annotation-xml") {
6082
- if (tag === "svg") {
6098
+ if (isSVGTag(tag)) {
6083
6099
  return 1;
6084
6100
  }
6085
6101
  if (parent.props.some(
@@ -6096,10 +6112,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6096
6112
  }
6097
6113
  }
6098
6114
  if (ns === 0) {
6099
- if (tag === "svg") {
6115
+ if (isSVGTag(tag)) {
6100
6116
  return 1;
6101
6117
  }
6102
- if (tag === "math") {
6118
+ if (isMathMLTag(tag)) {
6103
6119
  return 2;
6104
6120
  }
6105
6121
  }
@@ -6462,7 +6478,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6462
6478
  }
6463
6479
  function defaultHasMultipleChildren(node) {
6464
6480
  const children = node.children = node.children.filter(
6465
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6481
+ (c) => !isCommentOrWhitespace(c)
6466
6482
  );
6467
6483
  const child = children[0];
6468
6484
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -6723,7 +6739,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6723
6739
  exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
6724
6740
  exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
6725
6741
  exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
6726
- exports.Namespaces = Namespaces;
6727
6742
  exports.NewlineType = NewlineType;
6728
6743
  exports.NodeTypes = NodeTypes;
6729
6744
  exports.OPEN_BLOCK = OPEN_BLOCK;
@@ -6794,6 +6809,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6794
6809
  exports.defaultOnWarn = defaultOnWarn;
6795
6810
  exports.errorMessages = errorMessages;
6796
6811
  exports.extractIdentifiers = extractIdentifiers;
6812
+ exports.filterNonCommentChildren = filterNonCommentChildren;
6797
6813
  exports.findDir = findDir;
6798
6814
  exports.findProp = findProp;
6799
6815
  exports.forAliasRE = forAliasRE;
@@ -6807,8 +6823,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6807
6823
  exports.getVNodeHelper = getVNodeHelper;
6808
6824
  exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
6809
6825
  exports.hasScopeRef = hasScopeRef;
6826
+ exports.hasSingleChild = hasSingleChild;
6810
6827
  exports.helperNameMap = helperNameMap;
6811
6828
  exports.injectProp = injectProp;
6829
+ exports.isAllWhitespace = isAllWhitespace;
6830
+ exports.isCommentOrWhitespace = isCommentOrWhitespace;
6812
6831
  exports.isConstantNode = isConstantNode;
6813
6832
  exports.isCoreComponent = isCoreComponent;
6814
6833
  exports.isFnExpression = isFnExpression;
@@ -6823,6 +6842,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6823
6842
  exports.isMemberExpressionNode = isMemberExpressionNode;
6824
6843
  exports.isReferencedIdentifier = isReferencedIdentifier;
6825
6844
  exports.isSimpleIdentifier = isSimpleIdentifier;
6845
+ exports.isSingleIfBlock = isSingleIfBlock;
6826
6846
  exports.isSlotOutlet = isSlotOutlet;
6827
6847
  exports.isStaticArgOf = isStaticArgOf;
6828
6848
  exports.isStaticExp = isStaticExp;
@@ -6834,6 +6854,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6834
6854
  exports.isVPre = isVPre;
6835
6855
  exports.isVSlot = isVSlot;
6836
6856
  exports.isValidHTMLNesting = isValidHTMLNesting;
6857
+ exports.isWhitespaceText = isWhitespaceText;
6837
6858
  exports.locStub = locStub;
6838
6859
  exports.noopDirectiveTransform = noopDirectiveTransform;
6839
6860
  exports.parse = parse;