simplestyle-js 5.4.6 → 5.5.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.
@@ -133,7 +133,11 @@ function createSheet(ruleId, sheetContents) {
133
133
  // attempt to reuse the style tag, if it existed
134
134
  const existingTag = doc.getElementById?.(ruleId);
135
135
  const existing = Boolean(existingTag);
136
- const styleTag = existingTag ?? doc.createElement('style');
136
+ let styleTag = existingTag;
137
+ if (!styleTag) {
138
+ styleTag = doc.createElement('style');
139
+ styleTag.dataset.simplestyleCreatedAtRuntime = 'true';
140
+ }
137
141
  styleTag.id = ruleId;
138
142
  styleTag.innerHTML = sheetContents;
139
143
  out.existing = existing;
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "SimpleStyleRegistry", {
11
11
  /* eslint-disable unicorn/prefer-query-selector */ const doc = globalThis.document;
12
12
  class SimpleStyleRegistry {
13
13
  sheets = new Map();
14
+ _id = performance.now().toString();
14
15
  add(ruleId, contents) {
15
16
  if (this.sheets.has(ruleId) && doc) {
16
17
  const tag = doc.getElementById(ruleId);
@@ -45,4 +46,9 @@ ${contents}`, '');
45
46
  ...this.sheets.entries()
46
47
  ];
47
48
  }
49
+ /**
50
+ * unique ID for this registry, based on the time when it was created
51
+ */ get id() {
52
+ return this._id;
53
+ }
48
54
  }
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export declare class SimpleStyleRegistry {
8
8
  private sheets;
9
+ private _id;
9
10
  add(ruleId: string, contents: string): void;
10
11
  /**
11
12
  * returns the bare CSS to be injected into a <style /> tag
@@ -25,4 +26,8 @@ export declare class SimpleStyleRegistry {
25
26
  * won't work during local development
26
27
  */
27
28
  getRulesById(): [string, string][];
29
+ /**
30
+ * unique ID for this registry, based on the time when it was created
31
+ */
32
+ get id(): string;
28
33
  }
@@ -101,7 +101,11 @@ function createSheet(ruleId, sheetContents) {
101
101
  // attempt to reuse the style tag, if it existed
102
102
  const existingTag = doc.getElementById?.(ruleId);
103
103
  const existing = Boolean(existingTag);
104
- const styleTag = existingTag ?? doc.createElement('style');
104
+ let styleTag = existingTag;
105
+ if (!styleTag) {
106
+ styleTag = doc.createElement('style');
107
+ styleTag.dataset.simplestyleCreatedAtRuntime = 'true';
108
+ }
105
109
  styleTag.id = ruleId;
106
110
  styleTag.innerHTML = sheetContents;
107
111
  out.existing = existing;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export declare class SimpleStyleRegistry {
8
8
  private sheets;
9
+ private _id;
9
10
  add(ruleId: string, contents: string): void;
10
11
  /**
11
12
  * returns the bare CSS to be injected into a <style /> tag
@@ -25,4 +26,8 @@ export declare class SimpleStyleRegistry {
25
26
  * won't work during local development
26
27
  */
27
28
  getRulesById(): [string, string][];
29
+ /**
30
+ * unique ID for this registry, based on the time when it was created
31
+ */
32
+ get id(): string;
28
33
  }
@@ -6,6 +6,7 @@
6
6
  * React variant of this will come after the baseline one is created
7
7
  */ export class SimpleStyleRegistry {
8
8
  sheets = new Map();
9
+ _id = performance.now().toString();
9
10
  add(ruleId, contents) {
10
11
  if (this.sheets.has(ruleId) && doc) {
11
12
  const tag = doc.getElementById(ruleId);
@@ -40,4 +41,9 @@ ${contents}`, '');
40
41
  ...this.sheets.entries()
41
42
  ];
42
43
  }
44
+ /**
45
+ * unique ID for this registry, based on the time when it was created
46
+ */ get id() {
47
+ return this._id;
48
+ }
43
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplestyle-js",
3
- "version": "5.4.6",
3
+ "version": "5.5.0",
4
4
  "description": "An incredibly straightforward and simple CSS-in-JS solution with zero runtime dependencies, and out-of-the-box TypeScript support",
5
5
  "type": "module",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "postcss": "^8.5.6",
54
54
  "react": ">=18",
55
55
  "react-dom": ">=18",
56
- "@better-builds/ts-duality": "^1.1.0",
56
+ "@better-builds/ts-duality": "^1.2.5",
57
57
  "typescript": "^5.9.3",
58
58
  "vite": "^7.3.0",
59
59
  "vitest": "^4.0.16"