Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Renamed property change listener interfaces

  • Loading branch information...
commit ec628c8e66ef4eb872a18f3d47d2facc34ba9755 1 parent 0acb00d
Kris Kowal authored
61 README.md
Source Rendered
@@ -829,29 +829,24 @@ with method calls like `array.push`. All methods of a watched array
829 829 support change dispatch. In addition, arrays have a `set` method to
830 830 make setting the value at a particular index observable.
831 831
832   -- **PropertyChanges.addPropertyChangeListener(object, key, listener,
833   - before)**
834   -- **PropertyChanges.removePropertyChangeListener(object, key,
835   - listener, before)**
836   -- **PropertyChanges.dispatchPropertyChange(object, key, value,
837   - before)**
838   -- **PropertyChanges.addBeforePropertyChangeListener(object, key,
839   - listener)**
840   -- **PropertyChanges.removeBeforePropertyChangeListener(object, key,
841   - listener)**
842   -- **PropertyChanges.dispatchBeforePropertyChange(object, key, value)**
843   -- **PropertyChanges.getPropertyChangeDescriptor(object, key)**
  832 +- PropertyChanges.**add**OwnPropertyChange**Listener**(object, key, listener, before)
  833 +- PropertyChanges.**remove**OwnPropertyChange**Listener**(object, key, listener, before)
  834 +- PropertyChanges.**dispatch**OwnPropertyChange(object, key, value, before)
  835 +- PropertyChanges.add**Before**OwnPropertyChangeListener(object, key, listener)
  836 +- PropertyChanges.remove**Before**OwnPropertyChangeListener(object, key, listener)
  837 +- PropertyChanges.dispatch**Before**OwnPropertyChange(object, key, value)
  838 +- PropertyChanges.**get**OwnPropertyChange**Descriptor**(object, key)
844 839
845 840 All of these functions delegate to methods of the same name if one
846 841 exists on the object.
847 842
848   -- **object.addPropertyChangeListener(key, listener, before)**
849   -- **object.removePropertyChangeListener(key, listener, before)**
850   -- **object.dispatchPropertyChange(key, value)**
851   -- **object.addBeforePropertyChangeListener(key, listener)**
852   -- **object.removeBeforePropertyChangeListener(key, listener)**
853   -- **object.dispatchBeforePropertyChange(key, value)**
854   -- **object.getPropertyChangeDescriptor(key)**
  843 +- object.**add**OwnPropertyChange**Listener**(key, listener, before)
  844 +- object.**remove**OwnPropertyChange**Listener**(key, listener, before)
  845 +- object.**dispatch**OwnPropertyChange(key, value, before)
  846 +- object.add**Before**OwnPropertyChangeListener(key, listener)
  847 +- object.remove**Before**OwnPropertyChangeListener(key, listener)
  848 +- object.dispatch**Before**OwnPropertyChange(key, value)
  849 +- object.**get**OwnPropertyChange**Descriptor**(key)
855 850
856 851 Additionally, `PropertyChanges.prototype` can be **mixed into** other
857 852 types of objects to support the property change dispatch interface. All
@@ -870,13 +865,13 @@ or updates for any item in a map data structure.
870 865 With the `listen/array-changes` module required, `Array` can also
871 866 dispatch map changes for the values at each index.
872 867
873   -- **collection.addMapChangeListener(listener)**
874   -- **collection.removeMapChangeListener(listener)**
875   -- **collection.dispatchMapChange(key, value)**
876   -- **collection.addBeforeMapChangeListener(listener)**
877   -- **collection.removeBeforeMapChangeListener(listener)**
878   -- **collection.dispatchBeforeMapChange(key, value)**
879   -- **collection.getMapChangeDescriptor()**
  868 +- collection.**add**MapChangeListener(listener, before)
  869 +- collection.**remove**MapChangeListener(listener, before)
  870 +- collection.**dispatch**MapChange(key, value, before)
  871 +- collection.add**Before**MapChangeListener(listener)
  872 +- collection.remove**Before**MapChangeListener(listener)
  873 +- collection.dispatch**Before**MapChange(key, value)
  874 +- collection.**get**MapChange**Descriptor**()
880 875
881 876 The **listener** for a map change receives the `value`, `key`, and
882 877 collection `object` as arguments, the same pattern as a `forEach` or
@@ -896,13 +891,13 @@ A range change listener receives notifications when a range of values at
896 891 a particular position is added, removed, or replaced within an ordered
897 892 collection.
898 893
899   -- **collection.addRangeChangeListener(listener)**
900   -- **collection.removeRangeChangeListener(listener)**
901   -- **collection.dispatchRangeChange(plus, minus, index)**
902   -- **collection.addBeforeRangeChangeListener(listener)**
903   -- **collection.removeBeforeRangeChangeListener(listener)**
904   -- **collection.dispatchBeforeRangeChange(plus, minus, index)**
905   -- **collection.getRangeChangeDescriptor()**
  894 +- collection.**add**RangeChange**Listener**(listener, before)
  895 +- collection.**remove**RangeChange**Listener**(listener, before)
  896 +- collection.**dispatch**RangeChange(plus, minus, index, before)
  897 +- collection.add**Before**RangeChange**Listener**(listener)
  898 +- collection.remove**Before**RangeChange**Listener**(listener)
  899 +- collection.dispatch**Before**RangeChange(plus, minus, index)
  900 +- collection.**get**RangeChange**Descriptor**()
906 901
907 902 The **listener** for a range change is a function that accepts `plus`,
908 903 `minus`, and `index` arguments. `plus` and `minus` are the values that
4 demo/observable-array-demo.js
@@ -3,11 +3,11 @@ require("../listen/array-changes");
3 3
4 4 var array = [];
5 5
6   -array.addPropertyChangeListener("length", function (length) {
  6 +array.addOwnPropertyChangeListener("length", function (length) {
7 7 console.log("changed", length);
8 8 });
9 9
10   -array.addPropertyChangeListener(0, function (value) {
  10 +array.addOwnPropertyChangeListener(0, function (value) {
11 11 console.log("array[0] changed to", value);
12 12 });
13 13
24 listen/array-changes.js
@@ -63,7 +63,7 @@ var observableArrayProperties = {
63 63 // dispatch before change events
64 64 this.dispatchBeforeRangeChange(this, this, 0);
65 65 for (var i = 0; i < this.length; i++) {
66   - PropertyChanges.dispatchBeforePropertyChange(this, i, this[i]);
  66 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
67 67 this.dispatchBeforeMapChange(i, this[i]);
68 68 }
69 69
@@ -72,7 +72,7 @@ var observableArrayProperties = {
72 72
73 73 // dispatch after change events
74 74 for (var i = 0; i < this.length; i++) {
75   - PropertyChanges.dispatchPropertyChange(this, i, this[i]);
  75 + PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
76 76 this.dispatchMapChange(i, this[i]);
77 77 }
78 78 this.dispatchRangeChange(this, this, 0);
@@ -89,7 +89,7 @@ var observableArrayProperties = {
89 89 // dispatch before change events
90 90 this.dispatchBeforeRangeChange(this, this, 0);
91 91 for (var i = 0; i < this.length; i++) {
92   - PropertyChanges.dispatchBeforePropertyChange(this, i, this[i]);
  92 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
93 93 this.dispatchBeforeMapChange(i, this[i]);
94 94 }
95 95
@@ -98,7 +98,7 @@ var observableArrayProperties = {
98 98
99 99 // dispatch after change events
100 100 for (var i = 0; i < this.length; i++) {
101   - PropertyChanges.dispatchPropertyChange(this, i, this[i]);
  101 + PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
102 102 this.dispatchMapChange(i, this[i]);
103 103 }
104 104 this.dispatchRangeChange(this, this, 0);
@@ -120,20 +120,20 @@ var observableArrayProperties = {
120 120
121 121 // dispatch before change events
122 122 if (diff) {
123   - PropertyChanges.dispatchBeforePropertyChange(this, "length", this.length);
  123 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, "length", this.length);
124 124 }
125 125 this.dispatchBeforeRangeChange(plus, minus, start);
126 126 if (diff === 0) { // substring replacement
127 127 for (var i = start; i < start + plus.length; i++) {
128   - PropertyChanges.dispatchBeforePropertyChange(this, i, this[i]);
  128 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
129 129 this.dispatchBeforeMapChange(i, this[i]);
130 130 }
131   - } else if (PropertyChanges.hasPropertyChangeDescriptor(this)) {
  131 + } else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
132 132 // all subsequent values changed or shifted.
133 133 // avoid (longest - start) long walks if there are no
134 134 // registered descriptors.
135 135 for (var i = start; i < longest; i++) {
136   - PropertyChanges.dispatchBeforePropertyChange(this, i, this[i]);
  136 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
137 137 this.dispatchBeforeMapChange(i, this[i]);
138 138 }
139 139 }
@@ -144,21 +144,21 @@ var observableArrayProperties = {
144 144 // dispatch after change events
145 145 if (diff === 0) { // substring replacement
146 146 for (var i = start; i < start + plus.length; i++) {
147   - PropertyChanges.dispatchPropertyChange(this, i, this[i]);
  147 + PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
148 148 this.dispatchMapChange(i, this[i]);
149 149 }
150   - } else if (PropertyChanges.hasPropertyChangeDescriptor(this)) {
  150 + } else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
151 151 // all subsequent values changed or shifted.
152 152 // avoid (longest - start) long walks if there are no
153 153 // registered descriptors.
154 154 for (var i = start; i < longest; i++) {
155   - PropertyChanges.dispatchPropertyChange(this, i, this[i]);
  155 + PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
156 156 this.dispatchMapChange(i, this[i]);
157 157 }
158 158 }
159 159 this.dispatchRangeChange(plus, minus, start);
160 160 if (diff) {
161   - PropertyChanges.dispatchPropertyChange(this, "length", this.length);
  161 + PropertyChanges.dispatchOwnPropertyChange(this, "length", this.length);
162 162 }
163 163
164 164 return result;
90 listen/property-changes.js
@@ -34,7 +34,7 @@ var propertyChangeDescriptors = new WeakMap();
34 34 // book-keeping is probably not warranted since it would be rare for an
35 35 // observed object to no longer be observed unless it was about to be disposed
36 36 // of or reused as an observable. The only benefit would be in avoiding bulk
37   -// calls to dispatchPropertyChange events on objects that have no listeners.
  37 +// calls to dispatchOwnPropertyChange events on objects that have no listeners.
38 38
39 39 /*
40 40 To observe shallow property changes for a particular key of a particular
@@ -60,7 +60,7 @@ function PropertyChanges() {
60 60 throw new Error("This is an abstract interface. Mix it. Don't construct it");
61 61 }
62 62
63   -PropertyChanges.prototype.getPropertyChangeDescriptor = function (key) {
  63 +PropertyChanges.prototype.getOwnPropertyChangeDescriptor = function (key) {
64 64 if (!propertyChangeDescriptors.has(this)) {
65 65 propertyChangeDescriptors.set(this, {});
66 66 }
@@ -74,7 +74,7 @@ PropertyChanges.prototype.getPropertyChangeDescriptor = function (key) {
74 74 return objectPropertyChangeDescriptors[key];
75 75 };
76 76
77   -PropertyChanges.prototype.hasPropertyChangeDescriptor = function (key) {
  77 +PropertyChanges.prototype.hasOwnPropertyChangeDescriptor = function (key) {
78 78 if (!propertyChangeDescriptors.has(this)) {
79 79 return false;
80 80 }
@@ -88,12 +88,12 @@ PropertyChanges.prototype.hasPropertyChangeDescriptor = function (key) {
88 88 return true;
89 89 };
90 90
91   -PropertyChanges.prototype.addPropertyChangeListener = function (key, listener, beforeChange) {
  91 +PropertyChanges.prototype.addOwnPropertyChangeListener = function (key, listener, beforeChange) {
92 92 if (this.makeObservable && !this.isObservable) {
93 93 this.makeObservable(); // particularly for observable arrays, for
94 94 // their length property
95 95 }
96   - var descriptor = PropertyChanges.getPropertyChangeDescriptor(this, key);
  96 + var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
97 97 var listeners;
98 98 if (beforeChange) {
99 99 listeners = descriptor.willChangeListeners;
@@ -104,12 +104,12 @@ PropertyChanges.prototype.addPropertyChangeListener = function (key, listener, b
104 104 listeners.push(listener);
105 105 };
106 106
107   -PropertyChanges.prototype.addBeforePropertyChangeListener = function (key, listener) {
108   - return PropertyChanges.addPropertyChangeListener(this, key, listener, true);
  107 +PropertyChanges.prototype.addBeforeOwnPropertyChangeListener = function (key, listener) {
  108 + return PropertyChanges.addOwnPropertyChangeListener(this, key, listener, true);
109 109 };
110 110
111   -PropertyChanges.prototype.removePropertyChangeListener = function (key, listener, beforeChange) {
112   - var descriptor = PropertyChanges.getPropertyChangeDescriptor(this, key);
  111 +PropertyChanges.prototype.removeOwnPropertyChangeListener = function (key, listener, beforeChange) {
  112 + var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
113 113
114 114 var listeners;
115 115 if (beforeChange) {
@@ -129,12 +129,12 @@ PropertyChanges.prototype.removePropertyChangeListener = function (key, listener
129 129 }
130 130 };
131 131
132   -PropertyChanges.prototype.removeBeforePropertyChangeListener = function (key, listener) {
133   - return PropertyChanges.removePropertyChangeListener(this, key, listener, true);
  132 +PropertyChanges.prototype.removeBeforeOwnPropertyChangeListener = function (key, listener) {
  133 + return PropertyChanges.removeOwnPropertyChangeListener(this, key, listener, true);
134 134 };
135 135
136   -PropertyChanges.prototype.dispatchPropertyChange = function (key, value, beforeChange) {
137   - var descriptor = PropertyChanges.getPropertyChangeDescriptor(this, key);
  136 +PropertyChanges.prototype.dispatchOwnPropertyChange = function (key, value, beforeChange) {
  137 + var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);
138 138
139 139 var listeners;
140 140 if (beforeChange) {
@@ -164,8 +164,8 @@ PropertyChanges.prototype.dispatchPropertyChange = function (key, value, beforeC
164 164 }, this);
165 165 };
166 166
167   -PropertyChanges.prototype.dispatchBeforePropertyChange = function (key, listener) {
168   - return PropertyChanges.dispatchPropertyChange(this, key, listener, true);
  167 +PropertyChanges.prototype.dispatchBeforeOwnPropertyChange = function (key, listener) {
  168 + return PropertyChanges.dispatchOwnPropertyChange(this, key, listener, true);
169 169 };
170 170
171 171 PropertyChanges.prototype.makePropertyObservable = function (key) {
@@ -245,9 +245,9 @@ PropertyChanges.prototype.makePropertyObservable = function (key) {
245 245 if (value === overriddenDescriptor.value) {
246 246 return value;
247 247 }
248   - PropertyChanges.dispatchBeforePropertyChange(this, key, overriddenDescriptor.value);
  248 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, key, overriddenDescriptor.value);
249 249 overriddenDescriptor.value = value;
250   - PropertyChanges.dispatchPropertyChange(this, key, value);
  250 + PropertyChanges.dispatchOwnPropertyChange(this, key, value);
251 251 return value;
252 252 },
253 253 enumerable: overriddenDescriptor.enumerable,
@@ -270,7 +270,7 @@ PropertyChanges.prototype.makePropertyObservable = function (key) {
270 270 if (value === formerValue) {
271 271 return value;
272 272 }
273   - PropertyChanges.dispatchBeforePropertyChange(this, key, formerValue);
  273 + PropertyChanges.dispatchBeforeOwnPropertyChange(this, key, formerValue);
274 274 // call through to actual setter
275 275 if (overriddenDescriptor.set) {
276 276 overriddenDescriptor.set.apply(this, arguments)
@@ -282,7 +282,7 @@ PropertyChanges.prototype.makePropertyObservable = function (key) {
282 282 }
283 283 // dispatch the new value: the given value if there is
284 284 // no getter, or the actual value if there is one
285   - PropertyChanges.dispatchPropertyChange(this, key, value);
  285 + PropertyChanges.dispatchOwnPropertyChange(this, key, value);
286 286 return value;
287 287 },
288 288 enumerable: overriddenDescriptor.enumerable,
@@ -319,56 +319,56 @@ PropertyChanges.prototype.makePropertyUnobservable = function (key) {
319 319
320 320 // constructor functions
321 321
322   -PropertyChanges.getPropertyChangeDescriptor = function (object, key) {
323   - if (object.getPropertyChangeDescriptor) {
324   - return object.getPropertyChangeDescriptor(key);
  322 +PropertyChanges.getOwnPropertyChangeDescriptor = function (object, key) {
  323 + if (object.getOwnPropertyChangeDescriptor) {
  324 + return object.getOwnPropertyChangeDescriptor(key);
325 325 } else {
326   - return PropertyChanges.prototype.getPropertyChangeDescriptor.call(object, key);
  326 + return PropertyChanges.prototype.getOwnPropertyChangeDescriptor.call(object, key);
327 327 }
328 328 };
329 329
330   -PropertyChanges.hasPropertyChangeDescriptor = function (object, key) {
331   - if (object.hasPropertyChangeDescriptor) {
332   - return object.hasPropertyChangeDescriptor(key);
  330 +PropertyChanges.hasOwnPropertyChangeDescriptor = function (object, key) {
  331 + if (object.hasOwnPropertyChangeDescriptor) {
  332 + return object.hasOwnPropertyChangeDescriptor(key);
333 333 } else {
334   - return PropertyChanges.prototype.hasPropertyChangeDescriptor.call(object, key);
  334 + return PropertyChanges.prototype.hasOwnPropertyChangeDescriptor.call(object, key);
335 335 }
336 336 };
337 337
338   -PropertyChanges.addPropertyChangeListener = function (object, key, listener, beforeChange) {
339   - if (object.addPropertyChangeListener) {
340   - return object.addPropertyChangeListener(key, listener, beforeChange);
  338 +PropertyChanges.addOwnPropertyChangeListener = function (object, key, listener, beforeChange) {
  339 + if (object.addOwnPropertyChangeListener) {
  340 + return object.addOwnPropertyChangeListener(key, listener, beforeChange);
341 341 } else {
342   - return PropertyChanges.prototype.addPropertyChangeListener.call(object, key, listener, beforeChange);
  342 + return PropertyChanges.prototype.addOwnPropertyChangeListener.call(object, key, listener, beforeChange);
343 343 }
344 344 };
345 345
346   -PropertyChanges.removePropertyChangeListener = function (object, key, listener, beforeChange) {
347   - if (object.removePropertyChangeListener) {
348   - return object.removePropertyChangeListener(key, listener, beforeChange);
  346 +PropertyChanges.removeOwnPropertyChangeListener = function (object, key, listener, beforeChange) {
  347 + if (object.removeOwnPropertyChangeListener) {
  348 + return object.removeOwnPropertyChangeListener(key, listener, beforeChange);
349 349 } else {
350   - return PropertyChanges.prototype.removePropertyChangeListener.call(object, key, listener, beforeChange);
  350 + return PropertyChanges.prototype.removeOwnPropertyChangeListener.call(object, key, listener, beforeChange);
351 351 }
352 352 };
353 353
354   -PropertyChanges.dispatchPropertyChange = function (object, key, value, beforeChange) {
355   - if (object.dispatchPropertyChange) {
356   - return object.dispatchPropertyChange(key, value, beforeChange);
  354 +PropertyChanges.dispatchOwnPropertyChange = function (object, key, value, beforeChange) {
  355 + if (object.dispatchOwnPropertyChange) {
  356 + return object.dispatchOwnPropertyChange(key, value, beforeChange);
357 357 } else {
358   - return PropertyChanges.prototype.dispatchPropertyChange.call(object, key, value, beforeChange);
  358 + return PropertyChanges.prototype.dispatchOwnPropertyChange.call(object, key, value, beforeChange);
359 359 }
360 360 };
361 361
362   -PropertyChanges.addBeforePropertyChangeListener = function (object, key, listener) {
363   - return PropertyChanges.addPropertyChangeListener(object, key, listener, true);
  362 +PropertyChanges.addBeforeOwnPropertyChangeListener = function (object, key, listener) {
  363 + return PropertyChanges.addOwnPropertyChangeListener(object, key, listener, true);
364 364 };
365 365
366   -PropertyChanges.removeBeforePropertyChangeListener = function (object, key, listener) {
367   - return PropertyChanges.removePropertyChangeListener(object, key, listener, true);
  366 +PropertyChanges.removeBeforeOwnPropertyChangeListener = function (object, key, listener) {
  367 + return PropertyChanges.removeOwnPropertyChangeListener(object, key, listener, true);
368 368 };
369 369
370   -PropertyChanges.dispatchBeforePropertyChange = function (object, key, value) {
371   - return PropertyChanges.dispatchPropertyChange(object, key, value, true);
  370 +PropertyChanges.dispatchBeforeOwnPropertyChange = function (object, key, value) {
  371 + return PropertyChanges.dispatchOwnPropertyChange(object, key, value, true);
372 372 };
373 373
374 374 PropertyChanges.makePropertyObservable = function (object, key) {
12 spec/listen/array-changes-spec.js
@@ -11,11 +11,11 @@ describe("Array change dispatch", function () {
11 11
12 12 it("set up listeners", function () {
13 13
14   - array.addBeforePropertyChangeListener("length", function (length) {
  14 + array.addBeforeOwnPropertyChangeListener("length", function (length) {
15 15 spy("length change from", length);
16 16 });
17 17
18   - array.addPropertyChangeListener("length", function (length) {
  18 + array.addOwnPropertyChangeListener("length", function (length) {
19 19 spy("length change to", length);
20 20 });
21 21
@@ -322,12 +322,12 @@ describe("Array change dispatch", function () {
322 322
323 323 // mute all listeners
324 324
325   - var descriptor = array.getPropertyChangeDescriptor('length');
  325 + var descriptor = array.getOwnPropertyChangeDescriptor('length');
326 326 descriptor.willChangeListeners.forEach(function (listener) {
327   - array.removeBeforePropertyChangeListener('length', listener);
  327 + array.removeBeforeOwnPropertyChangeListener('length', listener);
328 328 });
329 329 descriptor.changeListeners.forEach(function (listener) {
330   - array.removePropertyChangeListener('length', listener);
  330 + array.removeOwnPropertyChangeListener('length', listener);
331 331 });
332 332
333 333 var descriptor = array.getRangeChangeDescriptor();
@@ -379,7 +379,7 @@ describe("Array change dispatch", function () {
379 379 it("observes length changes on arrays that are not otherwised observed", function () {
380 380 var array = [1, 2, 3];
381 381 var spy = jasmine.createSpy();
382   - array.addPropertyChangeListener("length", spy);
  382 + array.addOwnPropertyChangeListener("length", spy);
383 383 array.push(4);
384 384 expect(spy).toHaveBeenCalled();
385 385 });
16 spec/listen/property-changes-spec.js
@@ -12,10 +12,10 @@ describe("PropertyChanges", function () {
12 12 it("observes setter on object", function () {
13 13 spy = jasmine.createSpy();
14 14 var object = {};
15   - PropertyChanges.addBeforePropertyChangeListener(object, 'x', function (value, key) {
  15 + PropertyChanges.addBeforeOwnPropertyChangeListener(object, 'x', function (value, key) {
16 16 spy('from', value, key);
17 17 });
18   - PropertyChanges.addPropertyChangeListener(object, 'x', function (value, key) {
  18 + PropertyChanges.addOwnPropertyChangeListener(object, 'x', function (value, key) {
19 19 spy('to', value, key);
20 20 });
21 21 object.x = 10;
@@ -44,10 +44,10 @@ describe("PropertyChanges", function () {
44 44 configurable: true
45 45 }
46 46 });
47   - PropertyChanges.addBeforePropertyChangeListener(object, 'x', function (value, key) {
  47 + PropertyChanges.addBeforeOwnPropertyChangeListener(object, 'x', function (value, key) {
48 48 spy('from', value, key);
49 49 });
50   - PropertyChanges.addPropertyChangeListener(object, 'x', function (value, key) {
  50 + PropertyChanges.addOwnPropertyChangeListener(object, 'x', function (value, key) {
51 51 spy('to', value, key);
52 52 });
53 53 object.x = 10;
@@ -61,10 +61,10 @@ describe("PropertyChanges", function () {
61 61 it("handles cyclic own property change listeners", function () {
62 62 var a = {};
63 63 var b = {};
64   - PropertyChanges.addPropertyChangeListener(a, 'foo', function (value) {
  64 + PropertyChanges.addOwnPropertyChangeListener(a, 'foo', function (value) {
65 65 b.bar = value;
66 66 });
67   - PropertyChanges.addPropertyChangeListener(b, 'bar', function (value) {
  67 + PropertyChanges.addOwnPropertyChangeListener(b, 'bar', function (value) {
68 68 a.foo = value;
69 69 });
70 70 a.foo = 10;
@@ -79,7 +79,7 @@ describe("PropertyChanges", function () {
79 79 }
80 80 };
81 81 spyOn(object, "handlePropertyChange").andCallThrough();
82   - PropertyChanges.addPropertyChangeListener(object, "foo", object);
  82 + PropertyChanges.addOwnPropertyChangeListener(object, "foo", object);
83 83 object.foo = 10;
84 84 expect(object.handlePropertyChange).toHaveBeenCalled();
85 85 });
@@ -91,7 +91,7 @@ describe("PropertyChanges", function () {
91 91 }
92 92 };
93 93 spyOn(object, "handleFooChange").andCallThrough();
94   - PropertyChanges.addPropertyChangeListener(object, "foo", object);
  94 + PropertyChanges.addOwnPropertyChangeListener(object, "foo", object);
95 95 object.foo = 10;
96 96 expect(object.handleFooChange).toHaveBeenCalled();
97 97 });

0 comments on commit ec628c8

Please sign in to comment.
Something went wrong with that request. Please try again.