You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no option to convert HTML with keys in the attachElContent function.
If you are removing/adding/reordering elements these can get lost, and thus resulting in bad html.
In my project I fixed it now as following:
attachElContent: function(html) {
var convertHTMLWithKey = convertHTML.bind(null, {
getVNodeKey: function (attributes) {
console.log(attributes)
return attributes.id;
}
});
var newVirtualEl = convertHTMLWithKey(this.rootTemplate({
content: Backbone.$.trim(html)
}));
if (this.virtualEl) {
var patches = diff(this.virtualEl, newVirtualEl);
console.log(this.el, patches);
patch(this.el, patches);
}
else {
this.$el.html(Backbone.$.trim(html));
}
this.virtualEl = newVirtualEl;
return this;
},
Since attachElContent is called from the marionette code, you cannot add options. So still finding a correct way of fixing this.
The text was updated successfully, but these errors were encountered:
Hmm since attachElContent is called from Marionette it is not possible to add options.
I'll quickly explain the problem I ran into.
At our project we use dust template helpers to define our templates. So we add/remove things from the DOM on basis of properties in the backbone model. And there where I ran into problems with the virtual DOM. Since the virtual DOM compares the old DOM state to the new DOM state. If you remove an element from the DOM it compares it to the wrong element, and removes the wrong element. Since the function to compare the old DOM to the new DOM compares on the order in the DOM. With adding keys you create the correct order, so it doesn't compare the wrong elements. I know this is really a vague issue, and it took me 2 days to find out what was happening. You can find the ordering and the comparing is done in this file: https://github.com/Matt-Esch/virtual-dom/blob/master/vtree/diff.js
There is no option to convert HTML with keys in the attachElContent function.
If you are removing/adding/reordering elements these can get lost, and thus resulting in bad html.
In my project I fixed it now as following:
Since attachElContent is called from the marionette code, you cannot add options. So still finding a correct way of fixing this.
The text was updated successfully, but these errors were encountered: