1
|
"use strict";
|
2
|
|
3
|
exports.__esModule = true;
|
4
|
|
5
|
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
|
6
|
|
7
|
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
8
|
|
9
|
exports.JSXAttribute = JSXAttribute;
|
10
|
exports.JSXIdentifier = JSXIdentifier;
|
11
|
exports.JSXNamespacedName = JSXNamespacedName;
|
12
|
exports.JSXMemberExpression = JSXMemberExpression;
|
13
|
exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
14
|
exports.JSXExpressionContainer = JSXExpressionContainer;
|
15
|
exports.JSXSpreadChild = JSXSpreadChild;
|
16
|
exports.JSXText = JSXText;
|
17
|
exports.JSXElement = JSXElement;
|
18
|
exports.JSXOpeningElement = JSXOpeningElement;
|
19
|
exports.JSXClosingElement = JSXClosingElement;
|
20
|
exports.JSXEmptyExpression = JSXEmptyExpression;
|
21
|
|
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
|
24
|
function JSXAttribute(node) {
|
25
|
this.print(node.name, node);
|
26
|
if (node.value) {
|
27
|
this.token("=");
|
28
|
this.print(node.value, node);
|
29
|
}
|
30
|
}
|
31
|
|
32
|
function JSXIdentifier(node) {
|
33
|
this.word(node.name);
|
34
|
}
|
35
|
|
36
|
function JSXNamespacedName(node) {
|
37
|
this.print(node.namespace, node);
|
38
|
this.token(":");
|
39
|
this.print(node.name, node);
|
40
|
}
|
41
|
|
42
|
function JSXMemberExpression(node) {
|
43
|
this.print(node.object, node);
|
44
|
this.token(".");
|
45
|
this.print(node.property, node);
|
46
|
}
|
47
|
|
48
|
function JSXSpreadAttribute(node) {
|
49
|
this.token("{");
|
50
|
this.token("...");
|
51
|
this.print(node.argument, node);
|
52
|
this.token("}");
|
53
|
}
|
54
|
|
55
|
function JSXExpressionContainer(node) {
|
56
|
this.token("{");
|
57
|
this.print(node.expression, node);
|
58
|
this.token("}");
|
59
|
}
|
60
|
|
61
|
function JSXSpreadChild(node) {
|
62
|
this.token("{");
|
63
|
this.token("...");
|
64
|
this.print(node.expression, node);
|
65
|
this.token("}");
|
66
|
}
|
67
|
|
68
|
function JSXText(node) {
|
69
|
this.token(node.value);
|
70
|
}
|
71
|
|
72
|
function JSXElement(node) {
|
73
|
var open = node.openingElement;
|
74
|
this.print(open, node);
|
75
|
if (open.selfClosing) return;
|
76
|
|
77
|
this.indent();
|
78
|
for (var _iterator = node.children, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
|
79
|
var _ref;
|
80
|
|
81
|
if (_isArray) {
|
82
|
if (_i >= _iterator.length) break;
|
83
|
_ref = _iterator[_i++];
|
84
|
} else {
|
85
|
_i = _iterator.next();
|
86
|
if (_i.done) break;
|
87
|
_ref = _i.value;
|
88
|
}
|
89
|
|
90
|
var child = _ref;
|
91
|
|
92
|
this.print(child, node);
|
93
|
}
|
94
|
this.dedent();
|
95
|
|
96
|
this.print(node.closingElement, node);
|
97
|
}
|
98
|
|
99
|
function spaceSeparator() {
|
100
|
this.space();
|
101
|
}
|
102
|
|
103
|
function JSXOpeningElement(node) {
|
104
|
this.token("<");
|
105
|
this.print(node.name, node);
|
106
|
if (node.attributes.length > 0) {
|
107
|
this.space();
|
108
|
this.printJoin(node.attributes, node, { separator: spaceSeparator });
|
109
|
}
|
110
|
if (node.selfClosing) {
|
111
|
this.space();
|
112
|
this.token("/>");
|
113
|
} else {
|
114
|
this.token(">");
|
115
|
}
|
116
|
}
|
117
|
|
118
|
function JSXClosingElement(node) {
|
119
|
this.token("</");
|
120
|
this.print(node.name, node);
|
121
|
this.token(">");
|
122
|
}
|
123
|
|
124
|
function JSXEmptyExpression() {}
|