@vue/compiler-dom 3.6.0-alpha.2 → 3.6.0-alpha.4

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.2
2
+ * @vue/compiler-dom v3.6.0-alpha.4
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
  }
@@ -411,46 +411,46 @@ const transformTransition = (node, context) => {
411
411
  if (node.type === 1 && node.tagType === 1) {
412
412
  const component = context.isBuiltInComponent(node.tag);
413
413
  if (component === TRANSITION) {
414
- return () => {
415
- if (!node.children.length) {
416
- return;
417
- }
418
- if (hasMultipleChildren(node)) {
419
- context.onError(
420
- createDOMCompilerError(
421
- 62,
422
- {
423
- start: node.children[0].loc.start,
424
- end: node.children[node.children.length - 1].loc.end,
425
- source: ""
426
- }
427
- )
428
- );
429
- }
430
- const child = node.children[0];
431
- if (child.type === 1) {
432
- for (const p of child.props) {
433
- if (p.type === 7 && p.name === "show") {
434
- node.props.push({
435
- type: 6,
436
- name: "persisted",
437
- nameLoc: node.loc,
438
- value: void 0,
439
- loc: node.loc
440
- });
441
- }
442
- }
443
- }
444
- };
414
+ return postTransformTransition(node, context.onError);
445
415
  }
446
416
  }
447
417
  };
448
- function hasMultipleChildren(node) {
418
+ function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
419
+ return () => {
420
+ if (!node.children.length) {
421
+ return;
422
+ }
423
+ if (hasMultipleChildren(node)) {
424
+ onError(
425
+ createDOMCompilerError(62, {
426
+ start: node.children[0].loc.start,
427
+ end: node.children[node.children.length - 1].loc.end,
428
+ source: ""
429
+ })
430
+ );
431
+ }
432
+ const child = node.children[0];
433
+ if (child.type === 1) {
434
+ for (const p of child.props) {
435
+ if (p.type === 7 && p.name === "show") {
436
+ node.props.push({
437
+ type: 6,
438
+ name: "persisted",
439
+ nameLoc: node.loc,
440
+ value: void 0,
441
+ loc: node.loc
442
+ });
443
+ }
444
+ }
445
+ }
446
+ };
447
+ }
448
+ function defaultHasMultipleChildren(node) {
449
449
  const children = node.children = node.children.filter(
450
450
  (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
451
451
  );
452
452
  const child = children[0];
453
- return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
453
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
454
454
  }
455
455
 
456
456
  const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
@@ -525,7 +525,7 @@ const getCachedNode = (node) => {
525
525
  return node.codegenNode;
526
526
  }
527
527
  };
528
- const dataAriaRE = /^(data|aria)-/;
528
+ const dataAriaRE = /^(?:data|aria)-/;
529
529
  const isStringifiableAttr = (name, ns) => {
530
530
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
531
531
  };
@@ -536,6 +536,9 @@ function analyzeNode(node) {
536
536
  if (node.type === 1 && isNonStringifiable(node.tag)) {
537
537
  return false;
538
538
  }
539
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
540
+ return false;
541
+ }
539
542
  if (node.type === 12) {
540
543
  return [1, 0];
541
544
  }
@@ -929,6 +932,7 @@ exports.createDOMCompilerError = createDOMCompilerError;
929
932
  exports.isValidHTMLNesting = isValidHTMLNesting;
930
933
  exports.parse = parse;
931
934
  exports.parserOptions = parserOptions;
935
+ exports.postTransformTransition = postTransformTransition;
932
936
  exports.resolveModifiers = resolveModifiers;
933
937
  exports.transformStyle = transformStyle;
934
938
  Object.keys(compilerCore).forEach(function (k) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.2
2
+ * @vue/compiler-dom v3.6.0-alpha.4
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
  }
@@ -389,6 +389,44 @@ const transformShow = (dir, node, context) => {
389
389
  };
390
390
  };
391
391
 
392
+ function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
393
+ return () => {
394
+ if (!node.children.length) {
395
+ return;
396
+ }
397
+ if (hasMultipleChildren(node)) {
398
+ onError(
399
+ createDOMCompilerError(62, {
400
+ start: node.children[0].loc.start,
401
+ end: node.children[node.children.length - 1].loc.end,
402
+ source: ""
403
+ })
404
+ );
405
+ }
406
+ const child = node.children[0];
407
+ if (child.type === 1) {
408
+ for (const p of child.props) {
409
+ if (p.type === 7 && p.name === "show") {
410
+ node.props.push({
411
+ type: 6,
412
+ name: "persisted",
413
+ nameLoc: node.loc,
414
+ value: void 0,
415
+ loc: node.loc
416
+ });
417
+ }
418
+ }
419
+ }
420
+ };
421
+ }
422
+ function defaultHasMultipleChildren(node) {
423
+ const children = node.children = node.children.filter(
424
+ (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
425
+ );
426
+ const child = children[0];
427
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
428
+ }
429
+
392
430
  const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
393
431
  const stringifyStatic = (children, context, parent) => {
394
432
  if (context.scopes.vSlot > 0) {
@@ -461,7 +499,7 @@ const getCachedNode = (node) => {
461
499
  return node.codegenNode;
462
500
  }
463
501
  };
464
- const dataAriaRE = /^(data|aria)-/;
502
+ const dataAriaRE = /^(?:data|aria)-/;
465
503
  const isStringifiableAttr = (name, ns) => {
466
504
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
467
505
  };
@@ -472,6 +510,9 @@ function analyzeNode(node) {
472
510
  if (node.type === 1 && isNonStringifiable(node.tag)) {
473
511
  return false;
474
512
  }
513
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
514
+ return false;
515
+ }
475
516
  if (node.type === 12) {
476
517
  return [1, 0];
477
518
  }
@@ -849,6 +890,7 @@ exports.createDOMCompilerError = createDOMCompilerError;
849
890
  exports.isValidHTMLNesting = isValidHTMLNesting;
850
891
  exports.parse = parse;
851
892
  exports.parserOptions = parserOptions;
893
+ exports.postTransformTransition = postTransformTransition;
852
894
  exports.resolveModifiers = resolveModifiers;
853
895
  exports.transformStyle = transformStyle;
854
896
  Object.keys(compilerCore).forEach(function (k) {
@@ -1,4 +1,4 @@
1
- import { ParserOptions, NodeTransform, SourceLocation, CompilerError, ExpressionNode, SimpleExpressionNode, TransformContext, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
1
+ import { ParserOptions, NodeTransform, SourceLocation, CompilerError, ExpressionNode, SimpleExpressionNode, TransformContext, ComponentNode, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
2
2
  export * from '@vue/compiler-core';
3
3
 
4
4
  export declare const parserOptions: ParserOptions;
@@ -55,6 +55,8 @@ export declare const resolveModifiers: (key: ExpressionNode | string, modifiers:
55
55
  */
56
56
  export declare function isValidHTMLNesting(parent: string, child: string): boolean;
57
57
 
58
+ export declare function postTransformTransition(node: ComponentNode, onError: (error: CompilerError) => void, hasMultipleChildren?: (node: ComponentNode) => boolean): () => void;
59
+
58
60
  export declare const DOMNodeTransforms: NodeTransform[];
59
61
  export declare const DOMDirectiveTransforms: Record<string, DirectiveTransform>;
60
62
  export declare function compile(src: string | RootNode, options?: CompilerOptions): CodegenResult;