@cocreate/render 1.11.0 → 1.12.0
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 +12 -0
- package/package.json +1 -1
- package/src/index.js +24 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.11.0...v1.12.0) (2022-07-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* replace attribute value if new and old value are not equal ([3dc25d8](https://github.com/CoCreate-app/CoCreate-render/commit/3dc25d884510a6ad14455b232d9068eb5e1302a8))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* if oldValues same as new value will not update text, html or attributes ([9cfe3f0](https://github.com/CoCreate-app/CoCreate-render/commit/9cfe3f017e706a5a7211449c294158d60fa2098c))
|
|
12
|
+
|
|
1
13
|
# [1.11.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.10.0...v1.11.0) (2022-07-25)
|
|
2
14
|
|
|
3
15
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -208,6 +208,7 @@ const CoCreateRender = {
|
|
|
208
208
|
if (el.renderMap) {
|
|
209
209
|
let placeholder = el.renderMap.get(el)
|
|
210
210
|
if (placeholder){
|
|
211
|
+
let valueType = el.getAttribute('value-type')
|
|
211
212
|
renderKey = placeholder.renderKey
|
|
212
213
|
renderArray = placeholder.renderArray
|
|
213
214
|
if (renderArray)
|
|
@@ -216,7 +217,7 @@ const CoCreateRender = {
|
|
|
216
217
|
updateData = {[renderKey]: updateData}
|
|
217
218
|
let textContent = placeholder.placeholder
|
|
218
219
|
let text = that.__replaceValue(updateData, textContent, renderKey, valueType);
|
|
219
|
-
if (text)
|
|
220
|
+
if (text && text != el.renderedValue)
|
|
220
221
|
el.innerHTML = placeholder.placeholder
|
|
221
222
|
}
|
|
222
223
|
}
|
|
@@ -233,7 +234,8 @@ const CoCreateRender = {
|
|
|
233
234
|
|
|
234
235
|
if(placeholder){
|
|
235
236
|
let updateData = data;
|
|
236
|
-
|
|
237
|
+
// let oldValue = attrValue
|
|
238
|
+
let temp = placeholder.placeholder;
|
|
237
239
|
renderKey = placeholder.renderKey
|
|
238
240
|
renderArray = placeholder.renderArray
|
|
239
241
|
if (renderArray)
|
|
@@ -241,7 +243,9 @@ const CoCreateRender = {
|
|
|
241
243
|
if (renderKey)
|
|
242
244
|
updateData = {[renderKey]: updateData}
|
|
243
245
|
|
|
244
|
-
attrValue = that.__replaceValue(updateData,
|
|
246
|
+
attrValue = that.__replaceValue(updateData, temp, renderKey);
|
|
247
|
+
if (attrValue == attr.value)
|
|
248
|
+
attrValue = undefined
|
|
245
249
|
}
|
|
246
250
|
else
|
|
247
251
|
attrValue = that.__replaceValue(data, attrValue, renderKey);
|
|
@@ -279,24 +283,29 @@ const CoCreateRender = {
|
|
|
279
283
|
updateData = {[renderKey]: updateData}
|
|
280
284
|
text = that.__replaceValue(updateData, textContent, renderKey, valueType);
|
|
281
285
|
}
|
|
282
|
-
if (!text) {
|
|
286
|
+
if (!placeholder && !text) {
|
|
283
287
|
textContent = el.textContent;
|
|
284
288
|
that.renderMap(el, textContent, renderArray, renderKey)
|
|
285
289
|
text = that.__replaceValue(data, textContent, renderKey, valueType);
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
if (text || text == "") {
|
|
289
|
-
if (
|
|
290
|
-
el.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
if (text != el.renderedValue) {
|
|
294
|
+
el.renderedValue = text
|
|
295
|
+
if (valueType == 'text' || valueType == 'string'){
|
|
296
|
+
el.renderedValue = text
|
|
297
|
+
el.textContent = text;
|
|
298
|
+
} else {
|
|
299
|
+
const newNode = document.createElement('div');
|
|
300
|
+
newNode.innerHTML = text;
|
|
301
|
+
let parentElement = el.parentElement
|
|
302
|
+
parentElement.renderedValue = text
|
|
303
|
+
if (!parentElement.renderMap) {
|
|
304
|
+
that.renderMap(parentElement, textContent, renderArray, renderKey)
|
|
305
|
+
} else if (!parentElement['renderMap'].has(parentElement))
|
|
306
|
+
that.renderMap(parentElement, textContent, renderArray, renderKey)
|
|
307
|
+
el.replaceWith(...newNode.childNodes)
|
|
308
|
+
}
|
|
300
309
|
}
|
|
301
310
|
}
|
|
302
311
|
}
|
|
@@ -314,7 +323,6 @@ const CoCreateRender = {
|
|
|
314
323
|
dataOriginal: {},
|
|
315
324
|
data: function({selector, data, elements}) {
|
|
316
325
|
this.dataOriginal = {...data};
|
|
317
|
-
this.dataString = {...data};
|
|
318
326
|
delete this.dataOriginal.data
|
|
319
327
|
|
|
320
328
|
for (let element of elements)
|