@cocreate/lazy-loader 1.0.9 → 1.1.1

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,24 @@
1
+ ## [1.1.1](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.1.0...v1.1.1) (2022-07-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update pass-fetch and pass-filter attributes ([ef36769](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/ef36769bc387b51e0f6a7a231db20eb74cfad98f))
7
+
8
+ # [1.1.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.0.10...v1.1.0) (2022-06-23)
9
+
10
+
11
+ ### Features
12
+
13
+ * observe attributes if match found lazyload component ([755c88b](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/755c88b01222ebe85e51aa633be313a762e2d102))
14
+
15
+ ## [1.0.10](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.0.9...v1.0.10) (2022-06-18)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump dependencies ([8631da5](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/8631da5a9fa27aec4121899b9c913a70b1dfeb31))
21
+
1
22
  ## [1.0.9](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.0.8...v1.0.9) (2022-06-12)
2
23
 
3
24
 
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <a target="modal" href="module_activity_datatable.html"
72
72
  pass-collection="modules"
73
73
  pass-document_id=""
74
- pass-fetch_value=""
74
+ pass-filter-value=""
75
75
  pass-prefix=""
76
76
  pass-to="render"
77
77
  modal-width="600px"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/lazy-loader",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
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",
@@ -61,8 +61,8 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.3.2",
65
- "@cocreate/hosting": "^1.3.2",
66
- "@cocreate/observer": "^1.5.2"
64
+ "@cocreate/docs": "^1.3.3",
65
+ "@cocreate/hosting": "^1.3.3",
66
+ "@cocreate/observer": "^1.5.3"
67
67
  }
68
68
  }
package/src/index.js CHANGED
@@ -11,12 +11,12 @@ export function removeComponent(key) {
11
11
  function listen(callback, selector) {
12
12
 
13
13
  function observerCallback({ target }) {
14
- let isInit = target.querySelector(selector)
15
- if (isInit) {
14
+ // let isInit = target.querySelector(selector)
15
+ // if (isInit) {
16
16
  callback()
17
17
  // console.log('lazyloaded', selector)
18
18
  observer.uninit(observerCallback)
19
- }
19
+ // }
20
20
  }
21
21
 
22
22
  observer.init({
@@ -26,7 +26,32 @@ function listen(callback, selector) {
26
26
  callback: observerCallback
27
27
  })
28
28
 
29
- // todo: observer add attributes
29
+ let selectorAttributes = [];
30
+ let attributes = selector.split(",")
31
+ for (let attribute of attributes){
32
+ let attr = attribute.trim()
33
+ if (attr.startsWith("[")) {
34
+ let pos = attr.indexOf("*")
35
+ if (pos == -1)
36
+ pos = attr.indexOf("=")
37
+ if (pos !== -1) {
38
+ attr = attr.slice(1, pos)
39
+ } else {
40
+ attr = attr.slice(1, -1)
41
+ }
42
+ selectorAttributes.push(attr)
43
+ }
44
+
45
+ }
46
+ if (selectorAttributes.length > 0)
47
+ observer.init({
48
+ name: 'lazyloadAttributeObserver',
49
+ observe: ['attributes'],
50
+ attributeName: selectorAttributes,
51
+ target: selector,
52
+ callback: observerCallback
53
+ });
54
+
30
55
  }
31
56
 
32
57
  export async function lazyLoad(name, selector, cb) {