* Check if element is considered a constant element * * @param {ts.Node} el element to check * @returns {boolean}
( el: ts.Node )
| 74 | * @returns {boolean} |
| 75 | */ |
| 76 | function isConstantElement( |
| 77 | el: ts.Node |
| 78 | ): el is ts.JsxSelfClosingElement & boolean { |
| 79 | // We only handle self-closing el for now |
| 80 | // e.g: <img src="foo"/> |
| 81 | // TODO: We can support immutable children but later |
| 82 | if (!ts.isJsxSelfClosingElement(el)) { |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | // No attributes, e.g <br/> |
| 87 | return ( |
| 88 | !el.attributes || |
| 89 | !el.attributes.properties || |
| 90 | !el.attributes.properties.length || |
| 91 | // no mutable prop |
| 92 | !el.attributes.properties.find(isMutableProp) |
| 93 | ); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Visit nodes recursively and try to determine if node's |