This repository was archived by the owner on Feb 12, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 134
134
function removeListener ( objName , portName , id ) {
135
135
if ( listenerMap [ objName ] ) {
136
136
if ( typeof id === 'undefined' ) {
137
- listenerMap [ objName ] . receivers . forEach ( function ( receiver , idx ) {
138
- if ( receiver . portName === portName ) {
139
- listenerMap [ objName ] . receivers . splice ( idx , 1 ) ;
140
- }
137
+ listenerMap [ objName ] . receivers = listenerMap [ objName ] . receivers . filter ( function ( receiver ) {
138
+ return receiver . portName !== portName ;
141
139
} ) ;
142
140
} else {
143
141
listenerMap [ objName ] . receivers . some ( function ( receiver , idx ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " API Proxy for Google Chrome™" ,
3
- "version" : " 0.0.8 " ,
3
+ "version" : " 0.0.9 " ,
4
4
"manifest_version" : 2 ,
5
5
"minimum_chrome_version" : " 23" ,
6
6
"app" : {
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ chrome._api = (function (window) {
46
46
}
47
47
48
48
function invoke ( id , method , params ) {
49
+ delete chrome . runtime . lastError ;
49
50
window . postMessage ( {
50
51
jsonrpc : '2.0' ,
51
52
id : id ,
@@ -59,14 +60,16 @@ chrome._api = (function (window) {
59
60
60
61
if ( msg . jsonrpc && ! msg . method ) {
61
62
if ( msg . error ) {
62
- throw msg . error ;
63
- } else if ( msg . result ) {
64
- if ( callbackHash [ msg . id ] ) {
65
- callbackHash [ msg . id ] . apply ( undef , msg . result ) ;
66
- delete callbackHash [ msg . id ] ;
67
- } else if ( listenerHash [ msg . id ] ) {
68
- listenerHash [ msg . id ] . apply ( undef , msg . result ) ;
69
- }
63
+ chrome . runtime . lastError = {
64
+ message : msg . error
65
+ } ;
66
+ }
67
+
68
+ if ( callbackHash [ msg . id ] ) {
69
+ callbackHash [ msg . id ] . apply ( undef , msg . result ) ;
70
+ delete callbackHash [ msg . id ] ;
71
+ } else if ( listenerHash [ msg . id ] ) {
72
+ listenerHash [ msg . id ] . apply ( undef , msg . result ) ;
70
73
}
71
74
}
72
75
} , false ) ;
@@ -78,3 +81,5 @@ chrome._api = (function (window) {
78
81
} ;
79
82
80
83
} ( window ) ) ;
84
+
85
+ chrome . runtime = chrome . runtime || { } ;
You can’t perform that action at this time.
0 commit comments