slightlyoff / cassowary.js

Cassowary/JS, better, faster, future-ready
Other
1.69k stars 107 forks source link

Start the hashCode at 1 to work with invalid check like !!x.hashCode #45

Closed Timshel closed 9 years ago

Timshel commented 10 years ago

In HashTable.js the keyCode function is written as :

var keyCode = function(key) {
  var kc = (!!key.hashCode) ? key.hashCode : key.toString();
  return kc;
};

When the hashCode value is 0 then !!hashCode is false and the result of toString() is used.

On a Variable the toString is build using the current value, then when the internal value change it's keyCode value change. Trying to fetch a stored Variable after a change of value will then fail (For example when doing solver.suggestValue)