canjs / can-observe

Observable objects
https://canjs.com/doc/can-observe.html
MIT License
20 stars 2 forks source link

Unused variable definition: var change = old !== value; #1

Closed leoj3n closed 7 years ago

leoj3n commented 8 years ago

In this file: https://github.com/canjs/can-observe/blob/9f287a2986db577455c2924b692adcf6b5c93fad/can-observe.js#L22

Did you forget to use change? I'm imagining you defined it with the intention of using it like:

set: function(target, key, value){
  var old = target[key];
  var change = old !== value;
  if (change) {
    target[key] = value;
    can.batch.trigger(target, key, [value, old]);
  }
  return true;
}

Or did you add change to just illustrate a point?

Thanks!

matthewp commented 7 years ago

That makes sense to me, this is likely a bug. Let me see if I can create a breaking example.