Returns true if the JSX element has an attribute with the given name, regardless of its value.
(
node: ts.JsxElement | ts.JsxSelfClosingElement,
attributeName: string
)
| 326 | |
| 327 | /** Returns true if the JSX element has an attribute with the given name, regardless of its value. */ |
| 328 | private hasJsxAttribute( |
| 329 | node: ts.JsxElement | ts.JsxSelfClosingElement, |
| 330 | attributeName: string |
| 331 | ): boolean { |
| 332 | const attributes = ts.isJsxElement(node) |
| 333 | ? node.openingElement.attributes |
| 334 | : node.attributes; |
| 335 | |
| 336 | return attributes.properties.some( |
| 337 | attr => |
| 338 | ts.isJsxAttribute(attr) && |
| 339 | ts.isIdentifier(attr.name) && |
| 340 | attr.name.text === attributeName |
| 341 | ); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Get the string value of a JSX attribute (extracts from t() calls) |