| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.JSXAttribute = JSXAttribute;
|
|---|
| 7 | exports.JSXClosingElement = JSXClosingElement;
|
|---|
| 8 | exports.JSXClosingFragment = JSXClosingFragment;
|
|---|
| 9 | exports.JSXElement = JSXElement;
|
|---|
| 10 | exports.JSXEmptyExpression = JSXEmptyExpression;
|
|---|
| 11 | exports.JSXExpressionContainer = JSXExpressionContainer;
|
|---|
| 12 | exports.JSXFragment = JSXFragment;
|
|---|
| 13 | exports.JSXIdentifier = JSXIdentifier;
|
|---|
| 14 | exports.JSXMemberExpression = JSXMemberExpression;
|
|---|
| 15 | exports.JSXNamespacedName = JSXNamespacedName;
|
|---|
| 16 | exports.JSXOpeningElement = JSXOpeningElement;
|
|---|
| 17 | exports.JSXOpeningFragment = JSXOpeningFragment;
|
|---|
| 18 | exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
|---|
| 19 | exports.JSXSpreadChild = JSXSpreadChild;
|
|---|
| 20 | exports.JSXText = JSXText;
|
|---|
| 21 | function JSXAttribute(node) {
|
|---|
| 22 | this.print(node.name);
|
|---|
| 23 | if (node.value) {
|
|---|
| 24 | this.tokenChar(61);
|
|---|
| 25 | this.print(node.value);
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | function JSXIdentifier(node) {
|
|---|
| 29 | this.word(node.name);
|
|---|
| 30 | }
|
|---|
| 31 | function JSXNamespacedName(node) {
|
|---|
| 32 | this.print(node.namespace);
|
|---|
| 33 | this.tokenChar(58);
|
|---|
| 34 | this.print(node.name);
|
|---|
| 35 | }
|
|---|
| 36 | function JSXMemberExpression(node) {
|
|---|
| 37 | this.print(node.object);
|
|---|
| 38 | this.tokenChar(46);
|
|---|
| 39 | this.print(node.property);
|
|---|
| 40 | }
|
|---|
| 41 | function JSXSpreadAttribute(node) {
|
|---|
| 42 | this.tokenChar(123);
|
|---|
| 43 | this.token("...");
|
|---|
| 44 | this.print(node.argument);
|
|---|
| 45 | this.rightBrace(node);
|
|---|
| 46 | }
|
|---|
| 47 | function JSXExpressionContainer(node) {
|
|---|
| 48 | this.tokenChar(123);
|
|---|
| 49 | this.print(node.expression);
|
|---|
| 50 | this.rightBrace(node);
|
|---|
| 51 | }
|
|---|
| 52 | function JSXSpreadChild(node) {
|
|---|
| 53 | this.tokenChar(123);
|
|---|
| 54 | this.token("...");
|
|---|
| 55 | this.print(node.expression);
|
|---|
| 56 | this.rightBrace(node);
|
|---|
| 57 | }
|
|---|
| 58 | function JSXText(node) {
|
|---|
| 59 | const raw = this.getPossibleRaw(node);
|
|---|
| 60 | if (raw !== undefined) {
|
|---|
| 61 | this.token(raw, true);
|
|---|
| 62 | } else {
|
|---|
| 63 | this.token(node.value, true);
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 | function JSXElement(node) {
|
|---|
| 67 | const open = node.openingElement;
|
|---|
| 68 | this.print(open);
|
|---|
| 69 | if (open.selfClosing) return;
|
|---|
| 70 | this.indent();
|
|---|
| 71 | for (const child of node.children) {
|
|---|
| 72 | this.print(child);
|
|---|
| 73 | }
|
|---|
| 74 | this.dedent();
|
|---|
| 75 | this.print(node.closingElement);
|
|---|
| 76 | }
|
|---|
| 77 | function spaceSeparator() {
|
|---|
| 78 | this.space();
|
|---|
| 79 | }
|
|---|
| 80 | function JSXOpeningElement(node) {
|
|---|
| 81 | this.tokenChar(60);
|
|---|
| 82 | this.print(node.name);
|
|---|
| 83 | if (node.typeArguments) {
|
|---|
| 84 | this.print(node.typeArguments);
|
|---|
| 85 | }
|
|---|
| 86 | this.print(node.typeParameters);
|
|---|
| 87 | if (node.attributes.length > 0) {
|
|---|
| 88 | this.space();
|
|---|
| 89 | this.printJoin(node.attributes, undefined, undefined, spaceSeparator);
|
|---|
| 90 | }
|
|---|
| 91 | if (node.selfClosing) {
|
|---|
| 92 | this.space();
|
|---|
| 93 | this.tokenChar(47);
|
|---|
| 94 | }
|
|---|
| 95 | this.tokenChar(62);
|
|---|
| 96 | }
|
|---|
| 97 | function JSXClosingElement(node) {
|
|---|
| 98 | this.tokenChar(60);
|
|---|
| 99 | this.tokenChar(47);
|
|---|
| 100 | this.print(node.name);
|
|---|
| 101 | this.tokenChar(62);
|
|---|
| 102 | }
|
|---|
| 103 | function JSXEmptyExpression() {
|
|---|
| 104 | this.printInnerComments();
|
|---|
| 105 | }
|
|---|
| 106 | function JSXFragment(node) {
|
|---|
| 107 | this.print(node.openingFragment);
|
|---|
| 108 | this.indent();
|
|---|
| 109 | for (const child of node.children) {
|
|---|
| 110 | this.print(child);
|
|---|
| 111 | }
|
|---|
| 112 | this.dedent();
|
|---|
| 113 | this.print(node.closingFragment);
|
|---|
| 114 | }
|
|---|
| 115 | function JSXOpeningFragment() {
|
|---|
| 116 | this.tokenChar(60);
|
|---|
| 117 | this.tokenChar(62);
|
|---|
| 118 | }
|
|---|
| 119 | function JSXClosingFragment() {
|
|---|
| 120 | this.token("</");
|
|---|
| 121 | this.tokenChar(62);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | //# sourceMappingURL=jsx.js.map
|
|---|