source: trip-planner-front/node_modules/@babel/generator/lib/generators/jsx.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.JSXAttribute = JSXAttribute;
7exports.JSXIdentifier = JSXIdentifier;
8exports.JSXNamespacedName = JSXNamespacedName;
9exports.JSXMemberExpression = JSXMemberExpression;
10exports.JSXSpreadAttribute = JSXSpreadAttribute;
11exports.JSXExpressionContainer = JSXExpressionContainer;
12exports.JSXSpreadChild = JSXSpreadChild;
13exports.JSXText = JSXText;
14exports.JSXElement = JSXElement;
15exports.JSXOpeningElement = JSXOpeningElement;
16exports.JSXClosingElement = JSXClosingElement;
17exports.JSXEmptyExpression = JSXEmptyExpression;
18exports.JSXFragment = JSXFragment;
19exports.JSXOpeningFragment = JSXOpeningFragment;
20exports.JSXClosingFragment = JSXClosingFragment;
21
22var t = require("@babel/types");
23
24function JSXAttribute(node) {
25 this.print(node.name, node);
26
27 if (node.value) {
28 this.token("=");
29 this.print(node.value, node);
30 }
31}
32
33function JSXIdentifier(node) {
34 this.word(node.name);
35}
36
37function JSXNamespacedName(node) {
38 this.print(node.namespace, node);
39 this.token(":");
40 this.print(node.name, node);
41}
42
43function JSXMemberExpression(node) {
44 this.print(node.object, node);
45 this.token(".");
46 this.print(node.property, node);
47}
48
49function JSXSpreadAttribute(node) {
50 this.token("{");
51 this.token("...");
52 this.print(node.argument, node);
53 this.token("}");
54}
55
56function JSXExpressionContainer(node) {
57 this.token("{");
58 this.print(node.expression, node);
59 this.token("}");
60}
61
62function JSXSpreadChild(node) {
63 this.token("{");
64 this.token("...");
65 this.print(node.expression, node);
66 this.token("}");
67}
68
69function JSXText(node) {
70 const raw = this.getPossibleRaw(node);
71
72 if (raw != null) {
73 this.token(raw);
74 } else {
75 this.token(node.value);
76 }
77}
78
79function JSXElement(node) {
80 const open = node.openingElement;
81 this.print(open, node);
82 if (open.selfClosing) return;
83 this.indent();
84
85 for (const child of node.children) {
86 this.print(child, node);
87 }
88
89 this.dedent();
90 this.print(node.closingElement, node);
91}
92
93function spaceSeparator() {
94 this.space();
95}
96
97function JSXOpeningElement(node) {
98 this.token("<");
99 this.print(node.name, node);
100 this.print(node.typeParameters, node);
101
102 if (node.attributes.length > 0) {
103 this.space();
104 this.printJoin(node.attributes, node, {
105 separator: spaceSeparator
106 });
107 }
108
109 if (node.selfClosing) {
110 this.space();
111 this.token("/>");
112 } else {
113 this.token(">");
114 }
115}
116
117function JSXClosingElement(node) {
118 this.token("</");
119 this.print(node.name, node);
120 this.token(">");
121}
122
123function JSXEmptyExpression(node) {
124 this.printInnerComments(node);
125}
126
127function JSXFragment(node) {
128 this.print(node.openingFragment, node);
129 this.indent();
130
131 for (const child of node.children) {
132 this.print(child, node);
133 }
134
135 this.dedent();
136 this.print(node.closingFragment, node);
137}
138
139function JSXOpeningFragment() {
140 this.token("<");
141 this.token(">");
142}
143
144function JSXClosingFragment() {
145 this.token("</");
146 this.token(">");
147}
Note: See TracBrowser for help on using the repository browser.