@@ -51,11 +51,11 @@ export default class ToWidgetPostMessageApi {
51
51
if ( payload . response === undefined ) {
52
52
return ;
53
53
}
54
- const promise = this . _requestMap [ payload . _id ] ;
54
+ const promise = this . _requestMap [ payload . requestId ] ;
55
55
if ( ! promise ) {
56
56
return ;
57
57
}
58
- delete this . _requestMap [ payload . _id ] ;
58
+ delete this . _requestMap [ payload . requestId ] ;
59
59
promise . resolve ( payload ) ;
60
60
}
61
61
@@ -64,21 +64,21 @@ export default class ToWidgetPostMessageApi {
64
64
targetWindow = targetWindow || window . parent ; // default to parent window
65
65
targetOrigin = targetOrigin || "*" ;
66
66
this . _counter += 1 ;
67
- action . _id = Date . now ( ) + "-" + Math . random ( ) . toString ( 36 ) + "-" + this . _counter ;
67
+ action . requestId = Date . now ( ) + "-" + Math . random ( ) . toString ( 36 ) + "-" + this . _counter ;
68
68
69
69
return new Promise ( ( resolve , reject ) => {
70
- this . _requestMap [ action . _id ] = { resolve, reject} ;
70
+ this . _requestMap [ action . requestId ] = { resolve, reject} ;
71
71
targetWindow . postMessage ( action , targetOrigin ) ;
72
72
73
73
if ( this . _timeoutMs > 0 ) {
74
74
setTimeout ( ( ) => {
75
- if ( ! this . _requestMap [ action . _id ] ) {
75
+ if ( ! this . _requestMap [ action . requestId ] ) {
76
76
return ;
77
77
}
78
78
console . error ( "postMessage request timed out. Sent object: " + JSON . stringify ( action ) ,
79
79
this . _requestMap ) ;
80
- this . _requestMap [ action . _id ] . reject ( new Error ( "Timed out" ) ) ;
81
- delete this . _requestMap [ action . _id ] ;
80
+ this . _requestMap [ action . requestId ] . reject ( new Error ( "Timed out" ) ) ;
81
+ delete this . _requestMap [ action . requestId ] ;
82
82
} , this . _timeoutMs ) ;
83
83
}
84
84
} ) ;
0 commit comments