UNPKG

doly-icons

Version:

React icon component based on Bootstrap Icons

31 lines (30 loc) 997 B
import { isBrowser } from 'ut2'; import { injectStyle } from 'util-helpers'; // 插入样式节点缓存 var styleNodeCache = {}; // 插入样式 export var injectCss = function (css, key, options) { var _a; if (options === void 0) { options = {}; } if (!isBrowser) { return null; } if (styleNodeCache[key]) { if (((_a = options.csp) === null || _a === void 0 ? void 0 : _a.nonce) && styleNodeCache[key].nonce !== options.csp.nonce) { styleNodeCache[key].nonce = options.csp.nonce; } if (styleNodeCache[key].innerHTML !== css) { styleNodeCache[key].innerHTML = css; } return styleNodeCache[key]; } styleNodeCache[key] = injectStyle(css, { onBefore: function (style) { var _a; if ((_a = options.csp) === null || _a === void 0 ? void 0 : _a.nonce) { style.nonce = options.csp.nonce; } }, }); return styleNodeCache[key]; };