(node, path, isRoot)
| 149 | } |
| 150 | |
| 151 | function processNode(node, path, isRoot) { |
| 152 | const open = node.openingElement; |
| 153 | const name = getNameExpr(open.name); |
| 154 | const isFragment = isFragmentName(name); |
| 155 | |
| 156 | if (!isFragment) { |
| 157 | if (isComponentName(name)) { |
| 158 | raw('<'); |
| 159 | expr(name); |
| 160 | } |
| 161 | else { |
| 162 | raw('<'); |
| 163 | raw(name.name); |
| 164 | } |
| 165 | |
| 166 | if (open.attributes) { |
| 167 | for (let i = 0; i < open.attributes.length; i++) { |
| 168 | const attr = open.attributes[i]; |
| 169 | raw(' '); |
| 170 | if (t.isJSXSpreadAttribute(attr)) { |
| 171 | raw('...'); |
| 172 | expr(attr.argument); |
| 173 | continue; |
| 174 | } |
| 175 | const { name, value } = attr; |
| 176 | if (t.isJSXNamespacedName(name)) { |
| 177 | raw(name.namespace.name + ':' + name.name.name); |
| 178 | } |
| 179 | else { |
| 180 | raw(name.name); |
| 181 | } |
| 182 | if (value) { |
| 183 | raw('='); |
| 184 | if (value.expression) { |
| 185 | expr(value.expression); |
| 186 | } |
| 187 | else if (t.isStringLiteral(value)) { |
| 188 | escapePropValue(value); |
| 189 | } |
| 190 | else { |
| 191 | expr(value); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | processChildren(node, name, isFragment); |
| 199 | |
| 200 | if (isRoot) { |
| 201 | const template = t.templateLiteral(quasis, expressions); |
| 202 | const replacement = t.taggedTemplateExpression(tag, template); |
| 203 | path.replaceWith(replacement); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | function jsxVisitorHandler(path, state, isFragment) { |
| 208 | let quasisBefore = quasis; |
no test coverage detected
searching dependent graphs…