OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 var changeObservers = objectInfo.changeObservers; | 93 var changeObservers = objectInfo.changeObservers; |
94 if (changeObservers.indexOf(callback) >= 0) | 94 if (changeObservers.indexOf(callback) >= 0) |
95 return; | 95 return; |
96 | 96 |
97 changeObservers.push(callback); | 97 changeObservers.push(callback); |
98 } | 98 } |
99 | 99 |
100 function ObjectUnobserve(object, callback) { | 100 function ObjectUnobserve(object, callback) { |
101 if (!IS_SPEC_OBJECT(object)) | 101 if (!IS_SPEC_OBJECT(object)) |
102 throw MakeTypeError("observe_non_object", ["unobserve"]); | 102 throw MakeTypeError("observe_non_object", ["unobserve"]); |
| 103 if (!IS_SPEC_FUNCTION(callback)) |
| 104 throw MakeTypeError("observe_non_function", ["unobserve"]); |
103 | 105 |
104 var objectInfo = objectInfoMap.get(object); | 106 var objectInfo = objectInfoMap.get(object); |
105 if (IS_UNDEFINED(objectInfo)) | 107 if (IS_UNDEFINED(objectInfo)) |
106 return; | 108 return; |
107 | 109 |
108 var changeObservers = objectInfo.changeObservers; | 110 var changeObservers = objectInfo.changeObservers; |
109 var index = changeObservers.indexOf(callback); | 111 var index = changeObservers.indexOf(callback); |
110 if (index < 0) | 112 if (index < 0) |
111 return; | 113 return; |
112 | 114 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 "getNotifier", ObjectGetNotifier, | 233 "getNotifier", ObjectGetNotifier, |
232 "observe", ObjectObserve, | 234 "observe", ObjectObserve, |
233 "unobserve", ObjectUnobserve | 235 "unobserve", ObjectUnobserve |
234 )); | 236 )); |
235 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 237 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
236 "notify", ObjectNotifierNotify | 238 "notify", ObjectNotifierNotify |
237 )); | 239 )); |
238 } | 240 } |
239 | 241 |
240 SetupObjectObserve(); | 242 SetupObjectObserve(); |
OLD | NEW |