(obj: Record<string, any>)
| 25 | // - createObjectMatcher({ 'foo': '[bar]' }) matches { foo: bar } |
| 26 | // - createObjectMatcher({ '[foo]': 'bar' }) matches { [foo]: "bar" } |
| 27 | export function createObjectMatcher(obj: Record<string, any>): { |
| 28 | type: NodeTypes |
| 29 | properties: Partial<Property>[] |
| 30 | } { |
| 31 | return { |
| 32 | type: NodeTypes.JS_OBJECT_EXPRESSION, |
| 33 | properties: Object.keys(obj).map(key => ({ |
| 34 | type: NodeTypes.JS_PROPERTY, |
| 35 | key: { |
| 36 | type: NodeTypes.SIMPLE_EXPRESSION, |
| 37 | content: key.replace(bracketsRE, ''), |
| 38 | isStatic: !leadingBracketRE.test(key), |
| 39 | } as SimpleExpressionNode, |
| 40 | value: isString(obj[key]) |
| 41 | ? { |
| 42 | type: NodeTypes.SIMPLE_EXPRESSION, |
| 43 | content: obj[key].replace(bracketsRE, ''), |
| 44 | isStatic: !leadingBracketRE.test(obj[key]), |
| 45 | } |
| 46 | : obj[key], |
| 47 | })), |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | export function createElementWithCodegen( |
| 52 | tag: VNodeCall['tag'], |
no test coverage detected