Bläddra i källkod

bug with watch and subclasses

Adam Shaw 8 år sedan
förälder
incheckning
711c2103f4
1 ändrade filer med 3 tillägg och 7 borttagningar
  1. 3 7
      src/common/Model.js

+ 3 - 7
src/common/Model.js

@@ -302,13 +302,9 @@ var Model = Class.extend(EmitterMixin, ListenerMixin, {
 
 
 Model.watch = function(/* same arguments as this.watch() */) {
-	var proto = this.prototype;
-
-	if (!proto._globalWatchArgs) {
-		proto._globalWatchArgs = [];
-	}
-
-	proto._globalWatchArgs.push(arguments);
+	// creates new array every time, to not mess with subclass prototypes
+	// TODO: make more efficient
+	this.prototype._globalWatchArgs = (this.prototype._globalWatchArgs || []).concat(arguments);
 };