@zodash/load-css
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.1.0](https://github.com/zcorky/zodash/compare/@zodash/load-css@0.0.8...@zodash/load-css@0.1.0) (2022-08-24) | ||
### Features | ||
* **load-css:** support custom attributes like integrity, crossorigin ([9d36121](https://github.com/zcorky/zodash/commit/9d36121587f9965abe7972bcb517025e48345d3b)) | ||
## [0.0.8](https://github.com/zcorky/zodash/compare/@zodash/load-css@0.0.7...@zodash/load-css@0.0.8) (2021-12-04) | ||
@@ -8,0 +19,0 @@ |
@@ -0,1 +1,6 @@ | ||
export interface IOptions { | ||
integrity?: string; | ||
crossorigin?: string; | ||
[key: string]: any; | ||
} | ||
/** | ||
@@ -6,3 +11,3 @@ * dynamic load style | ||
*/ | ||
export declare function loadCss(path: string): Promise<void>; | ||
export declare function loadCss(path: string, options?: IOptions): Promise<void>; | ||
/** | ||
@@ -9,0 +14,0 @@ * dynamic load script using ajax |
@@ -9,5 +9,10 @@ "use strict"; | ||
*/ | ||
function loadCss(path) { | ||
function loadCss(path, options) { | ||
const attributes = options !== null && options !== void 0 ? options : {}; | ||
return new Promise((resolve, reject) => { | ||
const style = document.createElement('link'); | ||
for (const key in attributes) { | ||
// script.setAttribute(key, attributes[key]); | ||
style[key] = attributes[key]; | ||
} | ||
style.rel = 'stylesheet'; | ||
@@ -14,0 +19,0 @@ style.href = path; |
{ | ||
"name": "@zodash/load-css", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"description": "Dynamic load css file", | ||
@@ -70,3 +70,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "3f39603b0e00f0d4774e83895847eb9beba4963e" | ||
"gitHead": "49d0df78191e85b42300cddb3c9c076adb05fefe" | ||
} |
7258
100