@cocreate/elements 1.14.0 → 1.14.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 +8 -0
- package/demo/get-value.html +21 -23
- package/package.json +7 -7
- package/src/getValue.js +29 -35
- package/src/setValue.js +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.14.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.14.0...v1.14.1) (2022-12-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies ([d4637fa](https://github.com/CoCreate-app/CoCreate-elements/commit/d4637fa2089fbee92e3191704bcd65c9ac4d12fa))
|
|
7
|
+
* exclusively use element-prototype getValue and setValue ([5d4bc05](https://github.com/CoCreate-app/CoCreate-elements/commit/5d4bc05c27e5f83275547d2f32e6de363a6c744e))
|
|
8
|
+
|
|
1
9
|
# [1.14.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.31...v1.14.0) (2022-12-27)
|
|
2
10
|
|
|
3
11
|
|
package/demo/get-value.html
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<!--<ul get-value="#a123"> </ul>-->
|
|
13
|
-
<!--<ul id="a123"> hello </ul>-->
|
|
14
|
-
|
|
15
|
-
<input id="testing" value="new">
|
|
16
|
-
<h1 get-value="#testing" get-value-key="ty" class="{{ty}}" test="{{ty}}">{{ty}}</h1>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Value | CoCreateJS</title>
|
|
5
|
+
|
|
6
|
+
<!-- CoCreate Favicon -->
|
|
7
|
+
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
8
|
+
<!-- CoCreate CSS CDN -->
|
|
9
|
+
<link rel="stylesheet" href="https://cdn.cocreate.app/logic/latest/CoCreate-logic.min.css" type="text/css"/>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
<input id="testing" value="new">
|
|
14
|
+
<h1 get-value="#testing" get-value-key="ty" class="{{ty}}" test="{{ty}}">{{ty}}</h1>
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
<hr/>
|
|
17
|
+
|
|
18
|
+
<input id="testing1" value="new1" />
|
|
19
|
+
<input get-value="#testing1" />
|
|
20
|
+
<input get-value="#testing1" />
|
|
21
|
+
|
|
22
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
23
|
+
<!--<script src="../dist/CoCreate-form.js"></script>-->
|
|
24
|
+
|
|
25
|
+
</body>
|
|
28
26
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.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",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"webpack-log": "^3.0.1"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cocreate/actions": "^1.5.
|
|
64
|
-
"@cocreate/crud-client": "^1.17.
|
|
65
|
-
"@cocreate/docs": "^1.4.
|
|
66
|
-
"@cocreate/element-prototype": "^1.2.
|
|
67
|
-
"@cocreate/observer": "^1.5.
|
|
68
|
-
"@cocreate/utils": "^1.17.
|
|
63
|
+
"@cocreate/actions": "^1.5.45",
|
|
64
|
+
"@cocreate/crud-client": "^1.17.5",
|
|
65
|
+
"@cocreate/docs": "^1.4.27",
|
|
66
|
+
"@cocreate/element-prototype": "^1.2.17",
|
|
67
|
+
"@cocreate/observer": "^1.5.49",
|
|
68
|
+
"@cocreate/utils": "^1.17.9"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/getValue.js
CHANGED
|
@@ -57,47 +57,41 @@ function initEvents(valueEl, element, mutation){
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function setValueByFind(valueEl, mutation) {
|
|
60
|
-
let value;
|
|
61
|
-
// todo can be removed if all elements have getValue using prototype
|
|
62
|
-
if (valueEl.hasAttribute('value'))
|
|
63
|
-
value = valueEl.getAttribute('value');
|
|
64
|
-
else if (valueEl.getValue)
|
|
65
|
-
value = valueEl.getValue();
|
|
66
|
-
// else
|
|
67
|
-
// value = getValue(valueEl);
|
|
60
|
+
let value = valueEl.getValue();
|
|
68
61
|
if (!value) return;
|
|
62
|
+
|
|
69
63
|
let elements = mutation || valueEls.get(valueEl);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
if (elements) {
|
|
65
|
+
for(let element of elements){
|
|
66
|
+
let key = element.getAttribute('get-value-key');
|
|
67
|
+
if (key){
|
|
68
|
+
key = `{{${key}}}`;
|
|
69
|
+
const regex = new RegExp(key, "g");
|
|
70
|
+
for (let attribute of element.attributes){
|
|
71
|
+
let attrName = attribute.name;
|
|
72
|
+
let attrValue = attribute.value;
|
|
73
|
+
let setAttr = false;
|
|
74
|
+
if (attrValue.includes(key)){
|
|
75
|
+
attrValue = attrValue.replace(regex, value);
|
|
76
|
+
setAttr = true;
|
|
77
|
+
}
|
|
78
|
+
if (attrName.includes(key)){
|
|
79
|
+
element.removeAttribute(key);
|
|
80
|
+
attrName = attrName.replace(regex, value);
|
|
81
|
+
setAttr = true;
|
|
82
|
+
}
|
|
83
|
+
if (setAttr)
|
|
84
|
+
element.setAttribute(attrName, attrValue);
|
|
84
85
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
let html = element.innerHTML;
|
|
87
|
+
if (html.indexOf(key) !== -1){
|
|
88
|
+
html = html.replace(regex, value);
|
|
89
|
+
element.innerHTML = html;
|
|
89
90
|
}
|
|
90
|
-
if (setAttr)
|
|
91
|
-
element.setAttribute(attrName, attrValue);
|
|
92
|
-
}
|
|
93
|
-
let html = element.innerHTML;
|
|
94
|
-
if (html.indexOf(key) !== -1){
|
|
95
|
-
html = html.replace(regex, value);
|
|
96
|
-
element.innerHTML = html;
|
|
97
91
|
}
|
|
92
|
+
else
|
|
93
|
+
element.setValue(value);
|
|
98
94
|
}
|
|
99
|
-
else
|
|
100
|
-
element.setValue(value);
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
|
package/src/setValue.js
CHANGED