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

Function getStylesheetRules

src/shadow-embed.js:279–293  ·  view source on GitHub ↗

* @param {!Document} doc * @param {string} css * @return {?CSSRuleList}

(doc, css)

Source from the content-addressed store, hash-verified

277 * @return {?CSSRuleList}
278 */
279function getStylesheetRules(doc, css) {
280 const style = /** @type {!HTMLStyleElement} */ (doc.createElement('style'));
281 style./*OK*/ textContent = css;
282 try {
283 (doc.head || doc.documentElement).appendChild(style);
284 if (style.sheet) {
285 return /** @type {!CSSStyleSheet} */ (style.sheet).cssRules;
286 }
287 return null;
288 } finally {
289 if (style.parentNode) {
290 style.parentNode.removeChild(style);
291 }
292 }
293}
294
295/**
296 * @param {boolean|undefined} val

Callers 1

scopeShadowCssFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected