remy / bind.js

bind.js - simple two way data binding to HTML and callbacks
694 stars 62 forks source link

Multiple unnecessary dom updates #13

Closed sajov closed 8 years ago

sajov commented 8 years ago

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 8 years ago

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 8 years ago

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