MCPcopy Index your code
hub / github.com/ampproject/amphtml / getExistingStyleElement

Function getExistingStyleElement

src/style-installer.js:144–157  ·  view source on GitHub ↗

* @param {!Element|!ShadowRoot} cssRoot * @param {!{[key: string]: !Element}} styleMap * @param {string} key * @return {?Element}

(cssRoot, styleMap, key)

Source from the content-addressed store, hash-verified

142 * @return {?Element}
143 */
144function getExistingStyleElement(cssRoot, styleMap, key) {
145 // Already cached.
146 if (styleMap[key]) {
147 return styleMap[key];
148 }
149 // Check if the style has already been added by the server layout.
150 const existing = cssRoot./*OK*/ querySelector(`style[${key}], link[${key}]`);
151 if (existing) {
152 styleMap[key] = existing;
153 return existing;
154 }
155 // Nothing found.
156 return null;
157}
158
159/**
160 * Applies a transformer to the CSS text if it has been registered.

Callers 1

insertStyleElementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected