@@ -9,6 +9,35 @@ var v8tools;
9
9
10
10
var unique_id = 0 ;
11
11
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
+
12
41
function getUniqueId ( ) {
13
42
return ( unique_id ++ ) . toString ( ) ;
14
43
}
@@ -18,7 +47,7 @@ function wrapPromiseAsCallback(promise) {
18
47
if ( error )
19
48
promise . reject ( error ) ;
20
49
else
21
- promise . fulfill ( data ) ;
50
+ promise . fulfill ( createConstClone ( data ) ) ;
22
51
} ;
23
52
} ;
24
53
@@ -205,7 +234,8 @@ var EventTargetPrototype = function() {
205
234
var listeners = this . _event_listeners [ type ] ;
206
235
207
236
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 ) ) ) ;
209
239
} ;
210
240
211
241
// We need a reference to the calling object because
0 commit comments