MCPcopy Index your code
hub / github.com/dropbox/ts-transform-react-constant-elements / isConstantElement

Function isConstantElement

src/transform.ts:76–94  ·  view source on GitHub ↗

* Check if element is considered a constant element * * @param {ts.Node} el element to check * @returns {boolean}

(
  el: ts.Node
)

Source from the content-addressed store, hash-verified

74 * @returns {boolean}
75 */
76function 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

Callers 1

visitorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected