@cocreate/elements 1.42.6 → 1.42.7
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 +10 -0
- package/package.json +1 -1
- package/src/fetchSrc.js +5 -2
- package/src/form.js +8 -9
- package/src/index.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [1.42.7](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.6...v1.42.7) (2025-11-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* correct formatting in save function to ensure proper data handling ([19e0bdc](https://github.com/CoCreate-app/CoCreate-elements/commit/19e0bdccd02e95ffc4c0db22b7a96ad18bad663a))
|
|
7
|
+
* enhance setAttribute function to respect form-attributes and streamline attribute setting ([ce6c03b](https://github.com/CoCreate-app/CoCreate-elements/commit/ce6c03bfca08ac4634320725a72820fde49f604e))
|
|
8
|
+
* update filterData function to handle key-based data rendering ([2b4aecb](https://github.com/CoCreate-app/CoCreate-elements/commit/2b4aecb4f56ec0eb2666a56041b41f6191cb4e5e))
|
|
9
|
+
* update initElements function to correctly handle 'rendered' attribute and improve src validation ([a371968](https://github.com/CoCreate-app/CoCreate-elements/commit/a371968596c5c50a7f53c6f822ab7e432e985bad))
|
|
10
|
+
|
|
1
11
|
## [1.42.6](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.5...v1.42.6) (2025-10-10)
|
|
2
12
|
|
|
3
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.42.
|
|
3
|
+
"version": "1.42.7",
|
|
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/fetchSrc.js
CHANGED
|
@@ -37,9 +37,12 @@ async function initElements(elements) {
|
|
|
37
37
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
38
38
|
initMediaSource(element, src);
|
|
39
39
|
} else {
|
|
40
|
-
if (src && !textExtensions.includes(src.split('.').pop()))
|
|
41
|
-
element.removeAttribute("rendered");
|
|
40
|
+
if (src && !textExtensions.includes(src.split('.').pop())) continue
|
|
42
41
|
|
|
42
|
+
if (element.hasAttribute("rendered")) {
|
|
43
|
+
element.removeAttribute("rendered");
|
|
44
|
+
// continue;
|
|
45
|
+
}
|
|
43
46
|
let text = await response.text();
|
|
44
47
|
if (text) {
|
|
45
48
|
let path = "";
|
package/src/form.js
CHANGED
|
@@ -71,16 +71,15 @@ const formAttributesSelector = formAttributes.map((attr) => `[${attr}]`).join(",
|
|
|
71
71
|
*/
|
|
72
72
|
function setAttribute(form, elements) {
|
|
73
73
|
if (!elements) elements = form.querySelectorAll(formAttributesSelector);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
for (let el of elements) {
|
|
75
|
+
if (el.getAttribute("form-attributes") === "false") continue;
|
|
76
|
+
for (let attribute of form.attributes) {
|
|
77
|
+
if (!formAttributes.includes(attribute.name)) continue;
|
|
78
|
+
// let elArray = el.getAttribute("array");
|
|
79
|
+
// if (elArray && attribute.name === "array" && elArray !== attribute.value) break;
|
|
79
80
|
// Set the value of the attribute.
|
|
80
|
-
// TODO:
|
|
81
|
-
|
|
82
|
-
el.setAttribute(attribute.name, attribute.value);
|
|
83
|
-
}
|
|
81
|
+
// TODO: form-attributes="false" naming convention, perhaps skip by defualt if storage, database, array not the same and use attribute to apply for cases where one _id will be used across 2 arrays
|
|
82
|
+
el.setAttribute(attribute.name, attribute.value);
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|
package/src/index.js
CHANGED
|
@@ -551,6 +551,8 @@ async function filterData(element, data, type, key) {
|
|
|
551
551
|
) {
|
|
552
552
|
await checkFilters(element, data, type);
|
|
553
553
|
} else if (element.renderValue) {
|
|
554
|
+
if (key)
|
|
555
|
+
data = {[key]: data}
|
|
554
556
|
await element.renderValue(data);
|
|
555
557
|
} else if (key === "$length") {
|
|
556
558
|
element.setValue(data[type].length);
|
|
@@ -1114,7 +1116,7 @@ async function save(element, action) {
|
|
|
1114
1116
|
data[i].method = "object.update";
|
|
1115
1117
|
if (upsert) data[i].upsert = true;
|
|
1116
1118
|
}
|
|
1117
|
-
}
|
|
1119
|
+
}
|
|
1118
1120
|
}
|
|
1119
1121
|
|
|
1120
1122
|
if (data[i].isUpsert) {
|