chayns-components
Version:
A set of beautiful React components for developing chayns® applications.
30 lines (28 loc) • 710 B
JavaScript
;
exports.__esModule = true;
exports.default = loadStyle;
const styleMap = new Map();
function loadStyle(id, src) {
return new Promise((resolve, reject) => {
let styleTag = styleMap.get(id);
if (styleTag) {
resolve();
return;
}
if (!styleTag) {
styleTag = document.createElement('link');
styleTag.rel = 'stylesheet';
styleTag.type = 'text/css';
document.head.appendChild(styleTag);
styleMap.set(id, styleTag);
}
if (styleTag.href) {
styleTag.href = src;
} else {
styleTag.setAttribute('href', src);
}
styleTag.onload = resolve;
styleTag.onerror = reject;
});
}
//# sourceMappingURL=loadStyle.js.map