aliascss 1.3.3 → 1.3.4

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.
@@ -40,7 +40,32 @@ if (!window.AliasCSS) {
40
40
  // @ts-ignore
41
41
  window.AliasCSS = AliasCSS;
42
42
  }
43
- window.addEventListener('DOMContentLoaded', () => {
44
- AliasCSS.classPrinter.run();
45
- console.log(' AliasCSS is running');
46
- });
43
+ (() => {
44
+ const runScript = () => {
45
+ AliasCSS.classPrinter.run();
46
+ };
47
+ // 1. Run after initial DOM is ready
48
+ if (document.readyState === 'loading') {
49
+ document.addEventListener('DOMContentLoaded', runScript);
50
+ }
51
+ else {
52
+ runScript(); // DOM already parsed, run immediately
53
+ }
54
+ // 2. Re-run on every DOM change and attribute change
55
+ const observer = new MutationObserver(() => {
56
+ observer.disconnect(); // pause to avoid infinite loop
57
+ runScript();
58
+ observer.observe(document.body, {
59
+ childList: true,
60
+ subtree: true,
61
+ attributes: true,
62
+ attributeOldValue: true,
63
+ });
64
+ });
65
+ observer.observe(document.body, {
66
+ childList: true,
67
+ subtree: true,
68
+ attributes: true,
69
+ attributeOldValue: true,
70
+ });
71
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",