@vue/compiler-dom 3.5.21 → 3.5.22

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.5.21
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -533,6 +533,9 @@ function analyzeNode(node) {
533
533
  if (node.type === 1 && isNonStringifiable(node.tag)) {
534
534
  return false;
535
535
  }
536
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
537
+ return false;
538
+ }
536
539
  if (node.type === 12) {
537
540
  return [1, 0];
538
541
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.21
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -469,6 +469,9 @@ function analyzeNode(node) {
469
469
  if (node.type === 1 && isNonStringifiable(node.tag)) {
470
470
  return false;
471
471
  }
472
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
473
+ return false;
474
+ }
472
475
  if (node.type === 12) {
473
476
  return [1, 0];
474
477
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.21
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1647,7 +1647,8 @@ function walkFunctionParams(node, onIdent) {
1647
1647
  }
1648
1648
  }
1649
1649
  function walkBlockDeclarations(block, onIdent) {
1650
- for (const stmt of block.body) {
1650
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1651
+ for (const stmt of body) {
1651
1652
  if (stmt.type === "VariableDeclaration") {
1652
1653
  if (stmt.declare) continue;
1653
1654
  for (const decl of stmt.declarations) {
@@ -1660,6 +1661,8 @@ function walkBlockDeclarations(block, onIdent) {
1660
1661
  onIdent(stmt.id);
1661
1662
  } else if (isForStatement(stmt)) {
1662
1663
  walkForStatement(stmt, true, onIdent);
1664
+ } else if (stmt.type === "SwitchStatement") {
1665
+ walkSwitchStatement(stmt, true, onIdent);
1663
1666
  }
1664
1667
  }
1665
1668
  }
@@ -1676,6 +1679,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1676
1679
  }
1677
1680
  }
1678
1681
  }
1682
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1683
+ for (const cs of stmt.cases) {
1684
+ for (const stmt2 of cs.consequent) {
1685
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1686
+ for (const decl of stmt2.declarations) {
1687
+ for (const id of extractIdentifiers(decl.id)) {
1688
+ onIdent(id);
1689
+ }
1690
+ }
1691
+ }
1692
+ }
1693
+ walkBlockDeclarations(cs, onIdent);
1694
+ }
1695
+ }
1679
1696
  function extractIdentifiers(param, nodes = []) {
1680
1697
  switch (param.type) {
1681
1698
  case "Identifier":
@@ -4255,80 +4272,6 @@ function getParentCondition(node) {
4255
4272
  }
4256
4273
  }
4257
4274
 
4258
- const transformBind = (dir, _node, context) => {
4259
- const { modifiers, loc } = dir;
4260
- const arg = dir.arg;
4261
- let { exp } = dir;
4262
- if (exp && exp.type === 4 && !exp.content.trim()) {
4263
- {
4264
- exp = void 0;
4265
- }
4266
- }
4267
- if (!exp) {
4268
- if (arg.type !== 4 || !arg.isStatic) {
4269
- context.onError(
4270
- createCompilerError(
4271
- 52,
4272
- arg.loc
4273
- )
4274
- );
4275
- return {
4276
- props: [
4277
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4278
- ]
4279
- };
4280
- }
4281
- transformBindShorthand(dir);
4282
- exp = dir.exp;
4283
- }
4284
- if (arg.type !== 4) {
4285
- arg.children.unshift(`(`);
4286
- arg.children.push(`) || ""`);
4287
- } else if (!arg.isStatic) {
4288
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
4289
- }
4290
- if (modifiers.some((mod) => mod.content === "camel")) {
4291
- if (arg.type === 4) {
4292
- if (arg.isStatic) {
4293
- arg.content = camelize(arg.content);
4294
- } else {
4295
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4296
- }
4297
- } else {
4298
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4299
- arg.children.push(`)`);
4300
- }
4301
- }
4302
- if (!context.inSSR) {
4303
- if (modifiers.some((mod) => mod.content === "prop")) {
4304
- injectPrefix(arg, ".");
4305
- }
4306
- if (modifiers.some((mod) => mod.content === "attr")) {
4307
- injectPrefix(arg, "^");
4308
- }
4309
- }
4310
- return {
4311
- props: [createObjectProperty(arg, exp)]
4312
- };
4313
- };
4314
- const transformBindShorthand = (dir, context) => {
4315
- const arg = dir.arg;
4316
- const propName = camelize(arg.content);
4317
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4318
- };
4319
- const injectPrefix = (arg, prefix) => {
4320
- if (arg.type === 4) {
4321
- if (arg.isStatic) {
4322
- arg.content = prefix + arg.content;
4323
- } else {
4324
- arg.content = `\`${prefix}\${${arg.content}}\``;
4325
- }
4326
- } else {
4327
- arg.children.unshift(`'${prefix}' + (`);
4328
- arg.children.push(`)`);
4329
- }
4330
- };
4331
-
4332
4275
  const transformFor = createStructuralDirectiveTransform(
4333
4276
  "for",
4334
4277
  (node, dir, context) => {
@@ -4340,10 +4283,7 @@ const transformFor = createStructuralDirectiveTransform(
4340
4283
  const isTemplate = isTemplateNode(node);
4341
4284
  const memo = findDir(node, "memo");
4342
4285
  const keyProp = findProp(node, `key`, false, true);
4343
- const isDirKey = keyProp && keyProp.type === 7;
4344
- if (isDirKey && !keyProp.exp) {
4345
- transformBindShorthand(keyProp);
4346
- }
4286
+ keyProp && keyProp.type === 7;
4347
4287
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4348
4288
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4349
4289
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -5515,6 +5455,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
5515
5455
  return ret;
5516
5456
  };
5517
5457
 
5458
+ const transformBind = (dir, _node, context) => {
5459
+ const { modifiers, loc } = dir;
5460
+ const arg = dir.arg;
5461
+ let { exp } = dir;
5462
+ if (exp && exp.type === 4 && !exp.content.trim()) {
5463
+ {
5464
+ exp = void 0;
5465
+ }
5466
+ }
5467
+ if (arg.type !== 4) {
5468
+ arg.children.unshift(`(`);
5469
+ arg.children.push(`) || ""`);
5470
+ } else if (!arg.isStatic) {
5471
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
5472
+ }
5473
+ if (modifiers.some((mod) => mod.content === "camel")) {
5474
+ if (arg.type === 4) {
5475
+ if (arg.isStatic) {
5476
+ arg.content = camelize(arg.content);
5477
+ } else {
5478
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
5479
+ }
5480
+ } else {
5481
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
5482
+ arg.children.push(`)`);
5483
+ }
5484
+ }
5485
+ if (!context.inSSR) {
5486
+ if (modifiers.some((mod) => mod.content === "prop")) {
5487
+ injectPrefix(arg, ".");
5488
+ }
5489
+ if (modifiers.some((mod) => mod.content === "attr")) {
5490
+ injectPrefix(arg, "^");
5491
+ }
5492
+ }
5493
+ return {
5494
+ props: [createObjectProperty(arg, exp)]
5495
+ };
5496
+ };
5497
+ const injectPrefix = (arg, prefix) => {
5498
+ if (arg.type === 4) {
5499
+ if (arg.isStatic) {
5500
+ arg.content = prefix + arg.content;
5501
+ } else {
5502
+ arg.content = `\`${prefix}\${${arg.content}}\``;
5503
+ }
5504
+ } else {
5505
+ arg.children.unshift(`'${prefix}' + (`);
5506
+ arg.children.push(`)`);
5507
+ }
5508
+ };
5509
+
5518
5510
  const transformText = (node, context) => {
5519
5511
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
5520
5512
  return () => {
@@ -5845,9 +5837,35 @@ const transformMemo = (node, context) => {
5845
5837
  }
5846
5838
  };
5847
5839
 
5840
+ const transformVBindShorthand = (node, context) => {
5841
+ if (node.type === 1) {
5842
+ for (const prop of node.props) {
5843
+ if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
5844
+ const arg = prop.arg;
5845
+ if (arg.type !== 4 || !arg.isStatic) {
5846
+ context.onError(
5847
+ createCompilerError(
5848
+ 52,
5849
+ arg.loc
5850
+ )
5851
+ );
5852
+ prop.exp = createSimpleExpression("", true, arg.loc);
5853
+ } else {
5854
+ const propName = camelize(arg.content);
5855
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
5856
+ propName[0] === "-") {
5857
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
5858
+ }
5859
+ }
5860
+ }
5861
+ }
5862
+ }
5863
+ };
5864
+
5848
5865
  function getBaseTransformPreset(prefixIdentifiers) {
5849
5866
  return [
5850
5867
  [
5868
+ transformVBindShorthand,
5851
5869
  transformOnce,
5852
5870
  transformIf,
5853
5871
  transformMemo,
@@ -6602,4 +6620,4 @@ function parse(template, options = {}) {
6602
6620
  return baseParse(template, extend({}, parserOptions, options));
6603
6621
  }
6604
6622
 
6605
- 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, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
6623
+ 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, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, 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 };