@cocreate/elements 1.42.4 → 1.42.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 +8 -0
- package/package.json +1 -1
- package/src/fetchSrc.js +5 -13
- package/src/index.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.42.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.4...v1.42.5) (2025-10-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* ensure key checks in setData and filterData handle undefined values correctly ([fd04107](https://github.com/CoCreate-app/CoCreate-elements/commit/fd04107fde4d1d51ce215d3da5f241c47565aa92))
|
|
7
|
+
* import getRelativePath and remove unused getPath function in fetchSrc.js ([363497c](https://github.com/CoCreate-app/CoCreate-elements/commit/363497cd9fa0b2e920e226766488593e46f6db8f))
|
|
8
|
+
|
|
1
9
|
## [1.42.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.3...v1.42.4) (2025-09-07)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.42.
|
|
3
|
+
"version": "1.42.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/fetchSrc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import observer from "@cocreate/observer";
|
|
2
|
-
import { ObjectId } from "@cocreate/utils";
|
|
2
|
+
import { getRelativePath, ObjectId } from "@cocreate/utils";
|
|
3
3
|
|
|
4
4
|
const selector =
|
|
5
5
|
"[src]:not(img, video, audio, script, input, iframe, frame, link, source), [source], [stream]";
|
|
@@ -44,9 +44,11 @@ async function initElements(elements) {
|
|
|
44
44
|
let path = "";
|
|
45
45
|
let pathElement = element.closest("[path]");
|
|
46
46
|
if (pathElement) {
|
|
47
|
-
path =
|
|
47
|
+
path =
|
|
48
|
+
pathElement.getAttribute("path") ||
|
|
49
|
+
getRelativePath();
|
|
48
50
|
} else {
|
|
49
|
-
path =
|
|
51
|
+
path = getRelativePath();
|
|
50
52
|
}
|
|
51
53
|
// Replace $relativePath in the fetched text
|
|
52
54
|
if (path) {
|
|
@@ -66,16 +68,6 @@ async function initElements(elements) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
function getPath() {
|
|
70
|
-
let currentPath = window.location.pathname.replace(/\/[^\/]*$/, ""); // Remove file from path
|
|
71
|
-
if (!currentPath.endsWith("/")) {
|
|
72
|
-
currentPath += "/";
|
|
73
|
-
}
|
|
74
|
-
let depth = currentPath.split("/").filter(Boolean).length; // Count depth levels
|
|
75
|
-
|
|
76
|
-
return depth > 0 ? "../".repeat(depth) : "./"; // Return the correct relative path
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
async function initMediaSource(element, src) {
|
|
80
72
|
try {
|
|
81
73
|
let mediaConfig = await response.json();
|
package/src/index.js
CHANGED
|
@@ -430,11 +430,11 @@ async function setData(element, data) {
|
|
|
430
430
|
data[type][0] = { ...data[type][0], ...$update };
|
|
431
431
|
} else if (key === "$data") {
|
|
432
432
|
value = data;
|
|
433
|
-
} else if (key.startsWith("$data")) {
|
|
433
|
+
} else if (key && key.startsWith("$data")) {
|
|
434
434
|
value = CRUD.getValueFromObject(data, key.slice(1));
|
|
435
435
|
} else if (key === `$${type}`) {
|
|
436
436
|
value = data[type];
|
|
437
|
-
} else if (key.startsWith(`$${type}`)) {
|
|
437
|
+
} else if (key && key.startsWith(`$${type}`)) {
|
|
438
438
|
value = CRUD.getValueFromObject(data, key.slice(1));
|
|
439
439
|
} else if (key === "{}") {
|
|
440
440
|
value = data[type][0];
|
|
@@ -562,11 +562,11 @@ async function filterData(element, data, type, key) {
|
|
|
562
562
|
element.setValue(value.length);
|
|
563
563
|
} else if (key === "$data") {
|
|
564
564
|
value = data;
|
|
565
|
-
} else if (key.startsWith("$data")) {
|
|
565
|
+
} else if (key && key.startsWith("$data")) {
|
|
566
566
|
value = CRUD.getValueFromObject(data, key.slice(1));
|
|
567
567
|
} else if (key === `$${type}`) {
|
|
568
568
|
value = data[type];
|
|
569
|
-
} else if (key.startsWith(`$${type}`)) {
|
|
569
|
+
} else if (key && key.startsWith(`$${type}`)) {
|
|
570
570
|
value = CRUD.getValueFromObject(data, key.slice(1));
|
|
571
571
|
} else if (key === "{}") {
|
|
572
572
|
value = data[type][0];
|