doly-icons
Version:
React icon component based on Bootstrap Icons
33 lines (32 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectCss = void 0;
var ut2_1 = require("ut2");
var util_helpers_1 = require("util-helpers");
var styleNodeCache = {};
var injectCss = function (css, key, options) {
var _a;
if (options === void 0) { options = {}; }
if (!ut2_1.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] = (0, util_helpers_1.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];
};
exports.injectCss = injectCss;