OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // Overview: | 7 // Overview: |
8 // | 8 // |
9 // This file contains all of the routing and accounting for Object.observe. | 9 // This file contains all of the routing and accounting for Object.observe. |
10 // User code will interact with these mechanisms via the Object.observe APIs | 10 // User code will interact with these mechanisms via the Object.observe APIs |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (!ObjectInfoHasActiveObservers(objectInfo)) | 431 if (!ObjectInfoHasActiveObservers(objectInfo)) |
432 return; | 432 return; |
433 | 433 |
434 var hasType = !IS_UNDEFINED(type); | 434 var hasType = !IS_UNDEFINED(type); |
435 var newRecord = hasType ? | 435 var newRecord = hasType ? |
436 { object: ObjectInfoGetObject(objectInfo), type: type } : | 436 { object: ObjectInfoGetObject(objectInfo), type: type } : |
437 { object: ObjectInfoGetObject(objectInfo) }; | 437 { object: ObjectInfoGetObject(objectInfo) }; |
438 | 438 |
439 for (var prop in changeRecord) { | 439 for (var prop in changeRecord) { |
440 if (prop === 'object' || (hasType && prop === 'type')) continue; | 440 if (prop === 'object' || (hasType && prop === 'type')) continue; |
441 %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop], | 441 %AddProperty(newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE); |
442 READ_ONLY + DONT_DELETE); | |
443 } | 442 } |
444 ObjectFreezeJS(newRecord); | 443 ObjectFreezeJS(newRecord); |
445 | 444 |
446 ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord); | 445 ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord); |
447 } | 446 } |
448 | 447 |
449 function ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord) { | 448 function ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord) { |
450 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 449 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
451 if (IS_SYMBOL(changeRecord.name)) return; | 450 if (IS_SYMBOL(changeRecord.name)) return; |
452 | 451 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 "observe", ArrayObserve, | 631 "observe", ArrayObserve, |
633 "unobserve", ArrayUnobserve | 632 "unobserve", ArrayUnobserve |
634 )); | 633 )); |
635 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 634 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
636 "notify", ObjectNotifierNotify, | 635 "notify", ObjectNotifierNotify, |
637 "performChange", ObjectNotifierPerformChange | 636 "performChange", ObjectNotifierPerformChange |
638 )); | 637 )); |
639 } | 638 } |
640 | 639 |
641 SetupObjectObserve(); | 640 SetupObjectObserve(); |
OLD | NEW |