@cocreate/lazy-loader 1.12.1 → 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,10 @@
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
+
1
8
  ## [1.12.1](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.12.0...v1.12.1) (2023-12-20)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/lazy-loader",
3
- "version": "1.12.1",
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,6 +3,9 @@ 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
+
6
9
  if (window.CoCreate[name])
7
10
  return
8
11
  window.CoCreate[name] = {}
@@ -10,10 +13,7 @@ function listen(name, callback, selector) {
10
13
 
11
14
  const module = await callback()
12
15
  observer.uninit(observerCallback)
13
-
14
- Object.assign(window.CoCreate, {
15
- [name]: module.default || module
16
- });
16
+ window.CoCreate[name] = module.default || module
17
17
 
18
18
  dispatchComponentLoaded(name)
19
19
  }
@@ -62,10 +62,10 @@ export async function lazyLoad(name, selector, callback) {
62
62
 
63
63
  export async function dependency(name, promise) {
64
64
  let component = await promise;
65
+ if (!window.CoCreate)
66
+ window.CoCreate = {}
65
67
 
66
- Object.assign(window.CoCreate, {
67
- [name]: component.default || component
68
- });
68
+ window.CoCreate[name] = component.default || component
69
69
  dispatchComponentLoaded(name)
70
70
  }
71
71