Skip to content

Commit 3dc25d8

Browse files
committed
fix: replace attribute value if new and old value are not equal
1 parent 7747d72 commit 3dc25d8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/index.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,23 @@ const CoCreateRender = {
231231
else
232232
that.renderMap(attr, attr.value, renderArray, renderKey)
233233

234+
if (el.tagName == "P" && attr_name == 'document_id')
235+
console.log('tessssst')
236+
234237
if(placeholder){
235238
let updateData = data;
236-
attrValue = placeholder.placeholder;
239+
let oldValue = attrValue
240+
let temp = placeholder.placeholder;
237241
renderKey = placeholder.renderKey
238242
renderArray = placeholder.renderArray
239243
if (renderArray)
240244
updateData = data[renderArray][0]
241245
if (renderKey)
242246
updateData = {[renderKey]: updateData}
243247

244-
attrValue = that.__replaceValue(updateData, attrValue, renderKey);
248+
attrValue = that.__replaceValue(updateData, temp, renderKey);
249+
if (attrValue == oldValue)
250+
attrValue = undefined
245251
}
246252
else
247253
attrValue = that.__replaceValue(data, attrValue, renderKey);
@@ -279,7 +285,7 @@ const CoCreateRender = {
279285
updateData = {[renderKey]: updateData}
280286
text = that.__replaceValue(updateData, textContent, renderKey, valueType);
281287
}
282-
if (!text) {
288+
if (!placeholder && !text) {
283289
textContent = el.textContent;
284290
that.renderMap(el, textContent, renderArray, renderKey)
285291
text = that.__replaceValue(data, textContent, renderKey, valueType);

0 commit comments

Comments
 (0)