@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
  **/
@@ -64,7 +64,7 @@ const parserOptions = {
64
64
  let ns = parent ? parent.ns : rootNamespace;
65
65
  if (parent && ns === 2) {
66
66
  if (parent.tag === "annotation-xml") {
67
- if (tag === "svg") {
67
+ if (shared.isSVGTag(tag)) {
68
68
  return 1;
69
69
  }
70
70
  if (parent.props.some(
@@ -81,10 +81,10 @@ const parserOptions = {
81
81
  }
82
82
  }
83
83
  if (ns === 0) {
84
- if (tag === "svg") {
84
+ if (shared.isSVGTag(tag)) {
85
85
  return 1;
86
86
  }
87
- if (tag === "math") {
87
+ if (shared.isMathMLTag(tag)) {
88
88
  return 2;
89
89
  }
90
90
  }
@@ -447,7 +447,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
447
447
  }
448
448
  function defaultHasMultipleChildren(node) {
449
449
  const children = node.children = node.children.filter(
450
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
450
+ (c) => !compilerCore.isCommentOrWhitespace(c)
451
451
  );
452
452
  const child = children[0];
453
453
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -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
  **/
@@ -64,7 +64,7 @@ const parserOptions = {
64
64
  let ns = parent ? parent.ns : rootNamespace;
65
65
  if (parent && ns === 2) {
66
66
  if (parent.tag === "annotation-xml") {
67
- if (tag === "svg") {
67
+ if (shared.isSVGTag(tag)) {
68
68
  return 1;
69
69
  }
70
70
  if (parent.props.some(
@@ -81,10 +81,10 @@ const parserOptions = {
81
81
  }
82
82
  }
83
83
  if (ns === 0) {
84
- if (tag === "svg") {
84
+ if (shared.isSVGTag(tag)) {
85
85
  return 1;
86
86
  }
87
- if (tag === "math") {
87
+ if (shared.isMathMLTag(tag)) {
88
88
  return 2;
89
89
  }
90
90
  }
@@ -421,7 +421,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
421
421
  }
422
422
  function defaultHasMultipleChildren(node) {
423
423
  const children = node.children = node.children.filter(
424
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
424
+ (c) => !compilerCore.isCommentOrWhitespace(c)
425
425
  );
426
426
  const child = children[0];
427
427
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -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
  **/
@@ -49,6 +49,9 @@ const toHandlerKey = cacheStringFunction(
49
49
  return s;
50
50
  }
51
51
  );
52
+ const getModifierPropName = (name) => {
53
+ return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
54
+ };
52
55
 
53
56
  const PatchFlagNames = {
54
57
  [1]: `TEXT`,
@@ -260,14 +263,6 @@ function registerRuntimeHelpers(helpers) {
260
263
  });
261
264
  }
262
265
 
263
- const Namespaces = {
264
- "HTML": 0,
265
- "0": "HTML",
266
- "SVG": 1,
267
- "1": "SVG",
268
- "MATH_ML": 2,
269
- "2": "MATH_ML"
270
- };
271
266
  const NodeTypes = {
272
267
  "ROOT": 0,
273
268
  "0": "ROOT",
@@ -2106,7 +2101,43 @@ function getMemoedVNodeCall(node) {
2106
2101
  return node;
2107
2102
  }
2108
2103
  }
2104
+ function filterNonCommentChildren(node) {
2105
+ return node.children.filter((n) => n.type !== 3);
2106
+ }
2107
+ function hasSingleChild(node) {
2108
+ return filterNonCommentChildren(node).length === 1;
2109
+ }
2110
+ function isSingleIfBlock(parent) {
2111
+ let hasEncounteredIf = false;
2112
+ for (const c of filterNonCommentChildren(parent)) {
2113
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2114
+ if (hasEncounteredIf) return false;
2115
+ hasEncounteredIf = true;
2116
+ } else if (
2117
+ // node before v-if
2118
+ !hasEncounteredIf || // non else nodes
2119
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2120
+ ) {
2121
+ return false;
2122
+ }
2123
+ }
2124
+ return true;
2125
+ }
2109
2126
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2127
+ function isAllWhitespace(str) {
2128
+ for (let i = 0; i < str.length; i++) {
2129
+ if (!isWhitespace(str.charCodeAt(i))) {
2130
+ return false;
2131
+ }
2132
+ }
2133
+ return true;
2134
+ }
2135
+ function isWhitespaceText(node) {
2136
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2137
+ }
2138
+ function isCommentOrWhitespace(node) {
2139
+ return node.type === 3 || isWhitespaceText(node);
2140
+ }
2110
2141
 
2111
2142
  const defaultParserOptions = {
2112
2143
  parseMode: "base",
@@ -2729,14 +2760,6 @@ function condenseWhitespace(nodes) {
2729
2760
  }
2730
2761
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2731
2762
  }
2732
- function isAllWhitespace(str) {
2733
- for (let i = 0; i < str.length; i++) {
2734
- if (!isWhitespace(str.charCodeAt(i))) {
2735
- return false;
2736
- }
2737
- }
2738
- return true;
2739
- }
2740
2763
  function hasNewlineChar(str) {
2741
2764
  for (let i = 0; i < str.length; i++) {
2742
2765
  const c = str.charCodeAt(i);
@@ -4180,13 +4203,11 @@ function processIf(node, dir, context, processCodegen) {
4180
4203
  let i = siblings.indexOf(node);
4181
4204
  while (i-- >= -1) {
4182
4205
  const sibling = siblings[i];
4183
- if (sibling && sibling.type === 3) {
4184
- context.removeNode(sibling);
4185
- comments.unshift(sibling);
4186
- continue;
4187
- }
4188
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4206
+ if (sibling && isCommentOrWhitespace(sibling)) {
4189
4207
  context.removeNode(sibling);
4208
+ if (sibling.type === 3) {
4209
+ comments.unshift(sibling);
4210
+ }
4190
4211
  continue;
4191
4212
  }
4192
4213
  if (sibling && sibling.type === 9) {
@@ -4658,7 +4679,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4658
4679
  let prev;
4659
4680
  while (j--) {
4660
4681
  prev = children[j];
4661
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
4682
+ if (!isCommentOrWhitespace(prev)) {
4662
4683
  break;
4663
4684
  }
4664
4685
  }
@@ -4736,7 +4757,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4736
4757
  } else if (implicitDefaultChildren.length && // #3766
4737
4758
  // with whitespace: 'preserve', whitespaces between slots will end up in
4738
4759
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
4739
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
4760
+ !implicitDefaultChildren.every(isWhitespaceText)) {
4740
4761
  if (hasNamedDefaultSlot) {
4741
4762
  context.onError(
4742
4763
  createCompilerError(
@@ -4809,11 +4830,6 @@ function hasForwardedSlots(children) {
4809
4830
  }
4810
4831
  return false;
4811
4832
  }
4812
- function isNonWhitespaceContent(node) {
4813
- if (node.type !== 2 && node.type !== 12)
4814
- return true;
4815
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
4816
- }
4817
4833
 
4818
4834
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
4819
4835
  const transformElement = (node, context) => {
@@ -5710,7 +5726,7 @@ const transformModel$1 = (dir, node, context) => {
5710
5726
  ];
5711
5727
  if (dir.modifiers.length && node.tagType === 1) {
5712
5728
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
5713
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5729
+ const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5714
5730
  props.push(
5715
5731
  createObjectProperty(
5716
5732
  modifiersKey,
@@ -6076,7 +6092,7 @@ const parserOptions = {
6076
6092
  let ns = parent ? parent.ns : rootNamespace;
6077
6093
  if (parent && ns === 2) {
6078
6094
  if (parent.tag === "annotation-xml") {
6079
- if (tag === "svg") {
6095
+ if (isSVGTag(tag)) {
6080
6096
  return 1;
6081
6097
  }
6082
6098
  if (parent.props.some(
@@ -6093,10 +6109,10 @@ const parserOptions = {
6093
6109
  }
6094
6110
  }
6095
6111
  if (ns === 0) {
6096
- if (tag === "svg") {
6112
+ if (isSVGTag(tag)) {
6097
6113
  return 1;
6098
6114
  }
6099
- if (tag === "math") {
6115
+ if (isMathMLTag(tag)) {
6100
6116
  return 2;
6101
6117
  }
6102
6118
  }
@@ -6459,7 +6475,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
6459
6475
  }
6460
6476
  function defaultHasMultipleChildren(node) {
6461
6477
  const children = node.children = node.children.filter(
6462
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6478
+ (c) => !isCommentOrWhitespace(c)
6463
6479
  );
6464
6480
  const child = children[0];
6465
6481
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -6691,4 +6707,4 @@ function parse(template, options = {}) {
6691
6707
  return baseParse(template, extend({}, parserOptions, options));
6692
6708
  }
6693
6709
 
6694
- export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
6710
+ export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, filterNonCommentChildren, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, hasSingleChild, helperNameMap, injectProp, isAllWhitespace, isCommentOrWhitespace, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSingleIfBlock, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, isWhitespaceText, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };