@cocreate/elements 1.31.0 → 1.31.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,11 @@
1
+ ## [1.31.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.31.0...v1.31.1) (2023-12-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * if no elements retiurned do not fire fetchedData event ([44386d3](https://github.com/CoCreate-app/CoCreate-elements/commit/44386d34a1029f27e0af3caa7ec10813c5085062))
7
+ * improved data.$filter handling ([3ffaa6b](https://github.com/CoCreate-app/CoCreate-elements/commit/3ffaa6b9cc9a5e36b0fe5a9adcf58d99d7184920))
8
+
1
9
  # [1.31.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.30.0...v1.31.0) (2023-12-18)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.31.0",
3
+ "version": "1.31.1",
4
4
  "description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
5
5
  "keywords": [
6
6
  "elements",
package/src/index.js CHANGED
@@ -363,9 +363,14 @@ async function filterData(element, data, type, key) {
363
363
  } else if (data)
364
364
  element.setValue(data)
365
365
 
366
- if (data.$filter)
367
- filter.filters.get(element).index = data.$filter.index
366
+ if (data.$filter) {
367
+ let filterElement = filter.filters.get(element)
368
+ if (filterElement)
369
+ filterElement.index = data.$filter.index
370
+ }
368
371
 
372
+ if (!data[type] || !Array.isArray(data[type]) || !data[type].length)
373
+ return
369
374
  const evt = new CustomEvent('fetchedData', { bubbles: true });
370
375
  element.dispatchEvent(evt);
371
376
  }