@@ -9,6 +9,35 @@ var v8tools;
99
1010var unique_id = 0 ;
1111
12+ function addConstProperty ( obj , propertyKey , propertyValue ) {
13+ Object . defineProperty ( obj , propertyKey , {
14+ configurable : false ,
15+ writable : false ,
16+ value : propertyValue
17+ } ) ;
18+ }
19+
20+ function createConstClone ( obj ) {
21+ var const_obj = { } ;
22+ for ( var key in obj ) {
23+ if ( Array . isArray ( obj [ key ] ) ) {
24+ var obj_array = obj [ key ] ;
25+ var const_obj_array = [ ] ;
26+ for ( var i = 0 ; i < obj_array . length ; ++ i ) {
27+ var const_sub_obj = { } ;
28+ for ( var sub_key in obj_array [ i ] ) {
29+ addConstProperty ( const_sub_obj , sub_key , obj_array [ i ] [ sub_key ] ) ;
30+ }
31+ const_obj_array . push ( const_sub_obj ) ;
32+ }
33+ addConstProperty ( const_obj , key , const_obj_array ) ;
34+ } else {
35+ addConstProperty ( const_obj , key , obj [ key ] ) ;
36+ }
37+ }
38+ return const_obj ;
39+ }
40+
1241function getUniqueId ( ) {
1342 return ( unique_id ++ ) . toString ( ) ;
1443}
@@ -18,7 +47,7 @@ function wrapPromiseAsCallback(promise) {
1847 if ( error )
1948 promise . reject ( error ) ;
2049 else
21- promise . fulfill ( data ) ;
50+ promise . fulfill ( createConstClone ( data ) ) ;
2251 } ;
2352} ;
2453
@@ -205,7 +234,8 @@ var EventTargetPrototype = function() {
205234 var listeners = this . _event_listeners [ type ] ;
206235
207236 for ( var i in listeners )
208- listeners [ i ] ( new this . _event_synthesizers [ type ] ( type , data ) ) ;
237+ listeners [ i ] ( new this . _event_synthesizers [ type ] ( type ,
238+ createConstClone ( data ) ) ) ;
209239 } ;
210240
211241 // We need a reference to the calling object because
0 commit comments