@cocreate/lazy-loader 1.12.0 → 1.12.2

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.12.2](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.12.1...v1.12.2) (2023-12-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * if !window.CoCreate create ([cde6752](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/cde67522107f333b3178de8bc5487532636a59cb))
7
+
8
+ ## [1.12.1](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.12.0...v1.12.1) (2023-12-20)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * ensure observer only inits each component once ([9e1f051](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/9e1f0515b792cca169e32d20d18ccbd223dad7c1))
14
+
1
15
  # [1.12.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.11.4...v1.12.0) (2023-12-18)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/lazy-loader",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "A simple lazy-loader component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "lazy-loader",
package/src/client.js CHANGED
@@ -3,11 +3,17 @@ import observer from '@cocreate/observer';
3
3
  function listen(name, callback, selector) {
4
4
 
5
5
  async function observerCallback({ target }) {
6
+ if (!window.CoCreate)
7
+ window.CoCreate = {}
8
+
9
+ if (window.CoCreate[name])
10
+ return
11
+ window.CoCreate[name] = {}
12
+ observer.uninit(observerCallback)
13
+
6
14
  const module = await callback()
7
15
  observer.uninit(observerCallback)
8
- Object.assign(window.CoCreate, {
9
- [name]: module.default || module
10
- });
16
+ window.CoCreate[name] = module.default || module
11
17
 
12
18
  dispatchComponentLoaded(name)
13
19
  }
@@ -56,9 +62,10 @@ export async function lazyLoad(name, selector, callback) {
56
62
 
57
63
  export async function dependency(name, promise) {
58
64
  let component = await promise;
59
- Object.assign(window.CoCreate, {
60
- [name]: component.default || component
61
- });
65
+ if (!window.CoCreate)
66
+ window.CoCreate = {}
67
+
68
+ window.CoCreate[name] = component.default || component
62
69
  dispatchComponentLoaded(name)
63
70
  }
64
71