(state, pass)
| 37 | } |
| 38 | }, |
| 39 | post(state, pass) { |
| 40 | state.callee = pass.addHelper("jsx"); |
| 41 | // NOTE: The arguments passed to the "jsx" helper are: |
| 42 | // (element, props, key, ...children) or (element, props) |
| 43 | // The argument generated by the helper are: |
| 44 | // (element, { ...props, key }, ...children) |
| 45 | |
| 46 | const props = state.args[1]; |
| 47 | let hasKey = false; |
| 48 | if (t.isObjectExpression(props)) { |
| 49 | const keyIndex = props.properties.findIndex(prop => |
| 50 | // @ts-expect-error todo(flow->ts) key does not exist on SpreadElement |
| 51 | t.isIdentifier(prop.key, { name: "key" }), |
| 52 | ); |
| 53 | if (keyIndex > -1) { |
| 54 | // @ts-expect-error todo(flow->ts) value does not exist on ObjectMethod |
| 55 | state.args.splice(2, 0, props.properties[keyIndex].value); |
| 56 | props.properties.splice(keyIndex, 1); |
| 57 | hasKey = true; |
| 58 | } |
| 59 | } else if (t.isNullLiteral(props)) { |
| 60 | state.args.splice(1, 1, t.objectExpression([])); |
| 61 | } |
| 62 | |
| 63 | if (!hasKey && state.args.length > 2) { |
| 64 | state.args.splice(2, 0, t.buildUndefinedNode()); |
| 65 | } |
| 66 | |
| 67 | state.pure = true; |
| 68 | }, |
| 69 | }); |
| 70 | return { |
| 71 | name: "transform-react-inline-elements", |
nothing calls this directly
no test coverage detected