@cocreate/elements 1.34.3 → 1.34.5
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 +15 -0
- package/package.json +1 -1
- package/src/index.js +19 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.34.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.4...v1.34.5) (2024-02-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* data.object conditions ([d7f1431](https://github.com/CoCreate-app/CoCreate-elements/commit/d7f1431a70e48cf70dac8d219ab9f1c26df91a42))
|
|
7
|
+
* processing object.$update ([157f094](https://github.com/CoCreate-app/CoCreate-elements/commit/157f094d50bed51b94af9be272fdfc733b9f1cc6))
|
|
8
|
+
|
|
9
|
+
## [1.34.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.3...v1.34.4) (2024-02-19)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* minor bug fixes ([b136dda](https://github.com/CoCreate-app/CoCreate-elements/commit/b136dda0543ca1e3e558e38384fb4b447c455e05))
|
|
15
|
+
|
|
1
16
|
## [1.34.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.2...v1.34.3) (2024-02-18)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.5",
|
|
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
|
@@ -85,6 +85,8 @@ async function initElement(el) {
|
|
|
85
85
|
|
|
86
86
|
let data = getObject(el);
|
|
87
87
|
if (!data || !data.type) return
|
|
88
|
+
if (data.object && data.object !== 'pending' && !(/^[0-9a-fA-F]{24}$/.test(data.object)))
|
|
89
|
+
return
|
|
88
90
|
|
|
89
91
|
if (!elements.has(el)) {
|
|
90
92
|
elements.set(el, '')
|
|
@@ -202,8 +204,11 @@ function initDataKey(element, data) {
|
|
|
202
204
|
async function read(element, data, dataKey) {
|
|
203
205
|
if (!dataKey)
|
|
204
206
|
dataKey = { string: elements.get(element) }
|
|
205
|
-
if (!data)
|
|
206
|
-
|
|
207
|
+
if (!data) {
|
|
208
|
+
let existingData = keys.get(dataKey.string)
|
|
209
|
+
if (existingData && existingData.dataKey && existingData.dataKey.object)
|
|
210
|
+
data = { ...existingData.dataKey.object }
|
|
211
|
+
}
|
|
207
212
|
|
|
208
213
|
if (!dataKey || !data.type)
|
|
209
214
|
return
|
|
@@ -355,6 +360,11 @@ async function setData(element, data) {
|
|
|
355
360
|
else
|
|
356
361
|
value = 0
|
|
357
362
|
} else {
|
|
363
|
+
let $update = data[type][0].$update
|
|
364
|
+
if ($update) {
|
|
365
|
+
delete data[type][0].$update
|
|
366
|
+
data[type][0] = { ...data[type][0], ...$update }
|
|
367
|
+
}
|
|
358
368
|
value = CRUD.getValueFromObject(data[type][0], key)
|
|
359
369
|
}
|
|
360
370
|
|
|
@@ -390,6 +400,12 @@ async function filterData(element, data, type, key) {
|
|
|
390
400
|
let _id = element.getAttribute('object')
|
|
391
401
|
if (_id && doc._id !== _id)
|
|
392
402
|
return
|
|
403
|
+
let $update = doc.$update
|
|
404
|
+
if ($update) {
|
|
405
|
+
delete doc.$update
|
|
406
|
+
doc = { ...doc, ...$update }
|
|
407
|
+
}
|
|
408
|
+
|
|
393
409
|
}
|
|
394
410
|
if (doc[property]) {
|
|
395
411
|
if (Array.isArray(doc[property]))
|
|
@@ -467,6 +483,7 @@ async function checkFilters(element, data, type) {
|
|
|
467
483
|
if (!isMatch)
|
|
468
484
|
newData.slice(i, 1)
|
|
469
485
|
}
|
|
486
|
+
|
|
470
487
|
}
|
|
471
488
|
|
|
472
489
|
if (!newData || !newData.length)
|