[imp] changed get and set

bzr revid: nicolas.vanhoren@openerp.com-20120229102816-8wdpo4ybeq5zrsh7
This commit is contained in:
niv-openerp
2012-02-29 11:28:16 +01:00
parent 63edbe7359
commit 6dcc45a0bb
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -316,12 +316,12 @@ nova = (function() {
_.each(map, function(val, key) {
var tmp = self.__getterSetterInternalMap[key];
self.__getterSetterInternalMap[key] = val;
self.trigger("changed:" + key, {
self.trigger("change:" + key, self, {
oldValue: tmp,
newValue: val,
source: self
newValue: val
});
});
self.trigger("change", self);
},
get: function(key) {
return this.__getterSetterInternalMap[key];
+4 -4
View File
@@ -89,12 +89,12 @@ test("base", function() {
x.set({test: 1});
equal(x.get("test"), 1);
var tmp = 0;
x.bind("changed:test", y, function(arg) {
x.bind("change:test", y, function(model, options) {
tmp = 1;
equal(arg.oldValue, 1);
equal(arg.newValue, 2);
equal(options.oldValue, 1);
equal(options.newValue, 2);
equal(x.get("test"), 2);
equal(arg.source, x);
equal(model, x);
});
x.set({test: 2});
equal(tmp, 1);