MCPcopy Index your code
hub / github.com/developit/htm / processNode

Function processNode

packages/babel-plugin-transform-jsx-to-htm/index.mjs:151–205  ·  view source on GitHub ↗
(node, path, isRoot)

Source from the content-addressed store, hash-verified

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;

Callers 2

processChildrenFunction · 0.85
jsxVisitorHandlerFunction · 0.85

Calls 7

getNameExprFunction · 0.85
isFragmentNameFunction · 0.85
isComponentNameFunction · 0.85
rawFunction · 0.85
exprFunction · 0.85
escapePropValueFunction · 0.85
processChildrenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…