@cocreate/render 1.36.1 → 1.37.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 +19 -0
- package/package.json +1 -1
- package/src/index.js +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [1.37.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.37.0...v1.37.1) (2023-12-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* if no template.clone use template.template.clone ([ea678bf](https://github.com/CoCreate-app/CoCreate-render/commit/ea678bf3fa097349e431d7bf96f582a647d03a27))
|
|
7
|
+
|
|
8
|
+
# [1.37.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.36.1...v1.37.0) (2023-12-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* removed default ([01c1b1f](https://github.com/CoCreate-app/CoCreate-render/commit/01c1b1f8f5fa0159ae3399352e55a93e45b50678))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* attribute name rendering converts string to attributes ([30c6b25](https://github.com/CoCreate-app/CoCreate-render/commit/30c6b25b422cc9bbaa00c2f36ceafaaac302780d))
|
|
19
|
+
|
|
1
20
|
## [1.36.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.36.0...v1.36.1) (2023-12-15)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -130,7 +130,7 @@ async function render({ source, element, selector, data, key, index, currentInde
|
|
|
130
130
|
source = { data }
|
|
131
131
|
|
|
132
132
|
if (data.$filter) {
|
|
133
|
-
index = index || data.$filter.startingIndex
|
|
133
|
+
index = index || data.$filter.startingIndex || data.$filter.index
|
|
134
134
|
update = update || data.$filter.update
|
|
135
135
|
remove = remove || data.$filter.remove
|
|
136
136
|
}
|
|
@@ -244,6 +244,8 @@ async function renderTemplate(template, data, key, index, keyPath) {
|
|
|
244
244
|
|
|
245
245
|
let isInsert = data.$filter && (data.$filter.create || data.$filter.update)
|
|
246
246
|
if (!isInsert && !index || data.$filter.overwrite) {
|
|
247
|
+
if (!template.clones)
|
|
248
|
+
template = template.template
|
|
247
249
|
for (const [key, element] of template.clones) {
|
|
248
250
|
renderedNodes.delete(element)
|
|
249
251
|
element.remove()
|
|
@@ -476,11 +478,17 @@ async function renderValues(node, data, key, renderAs, keyPath, parent) {
|
|
|
476
478
|
|
|
477
479
|
name = await renderValue(attr, data, namePlaceholder, renderAs, renderedAttribute);
|
|
478
480
|
value = await renderValue(attr, data, valuePlaceholder, renderAs, renderedAttribute);
|
|
479
|
-
|
|
480
|
-
|
|
481
|
+
if (namePlaceholder.includes('{{') && name) {
|
|
482
|
+
const attributes = name.match(/([^\s]+="[^"]*"|[^\s]+)/g) || [];
|
|
483
|
+
attributes.forEach(attr => {
|
|
484
|
+
let [attributeName, attributeValue] = attr.split("=");
|
|
485
|
+
attributeValue = attributeValue ? attributeValue.replace(/"/g, '') : '';
|
|
486
|
+
node.setAttribute(attributeName, attributeValue);
|
|
487
|
+
});
|
|
488
|
+
} else if (name === undefined || name === null || name === '') {
|
|
481
489
|
renderedNodes.delete(attr)
|
|
482
490
|
node.removeAttribute(attr.name);
|
|
483
|
-
} else if ((value || value === "") && (name !== attr.name || value !== attr.value))
|
|
491
|
+
} else if (name && (value || value === "") && (name !== attr.name || value !== attr.value))
|
|
484
492
|
node.setAttribute(name, value);
|
|
485
493
|
}
|
|
486
494
|
// });
|
|
@@ -835,4 +843,4 @@ Observer.init({
|
|
|
835
843
|
|
|
836
844
|
init()
|
|
837
845
|
|
|
838
|
-
export
|
|
846
|
+
export { render, renderValue, sources, renderedNodes }
|