@thi.ng/hiccup-css 2.3.6 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/inject.d.ts +14 -2
- package/inject.js +5 -4
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2024-01-23T15:58:27Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.4.0) (2024-01-23)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add appendStyleSheet(), update injectStyleSheet() ([1eccb38](https://github.com/thi-ng/umbrella/commit/1eccb38))
|
|
17
|
+
|
|
12
18
|
### [2.3.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.3.4) (2023-12-22)
|
|
13
19
|
|
|
14
20
|
#### 🩹 Bug fixes
|
package/README.md
CHANGED
package/inject.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Injects given CSS string as global
|
|
3
|
-
* is true, inserts it as first stylesheet,
|
|
2
|
+
* Syntax sugar for {@link appendStyleSheet}. Injects given CSS string as global
|
|
3
|
+
* stylesheet in DOM head. If `first` is true, inserts it as first stylesheet,
|
|
4
|
+
* else (default) appends it.
|
|
4
5
|
*
|
|
5
6
|
* Returns created style DOM element.
|
|
6
7
|
*
|
|
@@ -8,4 +9,15 @@
|
|
|
8
9
|
* @param first - true, if prepend to stylesheet list (else append)
|
|
9
10
|
*/
|
|
10
11
|
export declare const injectStyleSheet: (css: string, first?: boolean) => HTMLStyleElement;
|
|
12
|
+
/**
|
|
13
|
+
* Injects given CSS string as <style> element and attaches it to `parent`. If
|
|
14
|
+
* `first` is true, inserts it as first child, else (default) appends it.
|
|
15
|
+
* Returns created style DOM element.
|
|
16
|
+
*
|
|
17
|
+
* @param css
|
|
18
|
+
* @param parent
|
|
19
|
+
* @param first
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const appendStyleSheet: (css: string, parent: Element | ShadowRoot, first?: boolean) => HTMLStyleElement;
|
|
11
23
|
//# sourceMappingURL=inject.d.ts.map
|
package/inject.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const injectStyleSheet = (css, first = false) =>
|
|
2
|
-
|
|
1
|
+
const injectStyleSheet = (css, first = false) => appendStyleSheet(css, document.head, first);
|
|
2
|
+
const appendStyleSheet = (css, parent, first = false) => {
|
|
3
3
|
const sheet = document.createElement("style");
|
|
4
4
|
sheet.setAttribute("type", "text/css");
|
|
5
5
|
if (sheet.styleSheet !== void 0) {
|
|
@@ -8,12 +8,13 @@ const injectStyleSheet = (css, first = false) => {
|
|
|
8
8
|
sheet.textContent = css;
|
|
9
9
|
}
|
|
10
10
|
if (first) {
|
|
11
|
-
|
|
11
|
+
parent.insertBefore(sheet, parent.firstChild);
|
|
12
12
|
} else {
|
|
13
|
-
|
|
13
|
+
parent.appendChild(sheet);
|
|
14
14
|
}
|
|
15
15
|
return sheet;
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
|
+
appendStyleSheet,
|
|
18
19
|
injectStyleSheet
|
|
19
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup-css",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "CSS from nested JS data structures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/checks": "^3.4.
|
|
40
|
-
"@thi.ng/errors": "^2.4.
|
|
41
|
-
"@thi.ng/transducers": "^8.8.
|
|
38
|
+
"@thi.ng/api": "^8.9.17",
|
|
39
|
+
"@thi.ng/checks": "^3.4.17",
|
|
40
|
+
"@thi.ng/errors": "^2.4.11",
|
|
41
|
+
"@thi.ng/transducers": "^8.8.21"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@microsoft/api-extractor": "^7.39.0",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
],
|
|
127
127
|
"year": 2016
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "417b5a7ea7bd54a3b4f086fe0fc2ce8e8933c9b2\n"
|
|
130
130
|
}
|