remy/bind.js

Multiple unnecessary dom updates

Closed this issue · 2 comments

sajov commented

example of the side effect that i'am talking about is shown in this example below
https://jsbin.com/fomaminoza/1/edit?html,js,console,output

(typeof settings.mapping[path.join('.')] != 'undefined') 

I strongly believe that only mapped values should trigger the callback.

that brings me to the conclusion that objects have the same problem:

{
me.price: {net:100, tax: 1.19}
}, {
'me.price': {
 dom:'div#somediv',
 transform: function(obj) {
     //bind.js inject the whole me.price object ! 
    return obj.net*obj.tax;
}
}
}

transform is triggered for each object property and is't parent's instead of only it's bound properties .
I have made a fix for the init state, but not for that object issue.

thurt commented

I strongly believe that only mapped values should trigger the callback.

I noticed this too--I'm getting multiple callbacks in number which matches the number of json nests + properties in last nest.

remy commented

Fixed and live in 1.1.0 (also in the dist dir).