/** * 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. * * */ import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; // $FlowFixMe: HTMLStyleElement is incorrectly typed - https://github.com/facebook/flow/issues/2696 export default function createCSSStyleSheet(id) { if (canUseDOM) { var element = document.getElementById(id); if (element != null) { // $FlowFixMe: HTMLElement is incorrectly typed return element.sheet; } else { var _element = document.createElement('style'); _element.setAttribute('id', id); var head = document.head; if (head) { head.insertBefore(_element, head.firstChild); } return _element.sheet; } } else { return null; } }