Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 31x 25x 25x 5x 20x 20x 20x 20x 20x 20x 6x | /**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
*/
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
// $FlowFixMe: HTMLStyleElement is incorrectly typed - https://github.com/facebook/flow/issues/2696
export default function createCSSStyleSheet(id: string): ?CSSStyleSheet {
if (canUseDOM) {
const element = document.getElementById(id);
if (element != null) {
// $FlowFixMe: HTMLElement is incorrectly typed
return element.sheet;
} else {
const element = document.createElement('style');
element.setAttribute('id', id);
const head = document.head;
Eif (head) {
head.insertBefore(element, head.firstChild);
}
return element.sheet;
}
} else {
return null;
}
}
|