Skip to content

Commit

Permalink
fix(http): inherit object properties on window.XMLHttpRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsChaceD committed Sep 14, 2023
1 parent 9048432 commit 5cd3b2f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions android/capacitor/src/main/assets/native-bridge.js
Expand Up @@ -394,6 +394,7 @@ var nativeBridge = (function (exports) {
win.CapacitorWebXMLHttpRequest = {
abort: window.XMLHttpRequest.prototype.abort,
constructor: window.XMLHttpRequest.prototype.constructor,
fullObject: window.XMLHttpRequest,
getAllResponseHeaders: window.XMLHttpRequest.prototype.getAllResponseHeaders,
getResponseHeader: window.XMLHttpRequest.prototype.getResponseHeader,
open: window.XMLHttpRequest.prototype.open,
Expand Down Expand Up @@ -674,6 +675,7 @@ var nativeBridge = (function (exports) {
Object.setPrototypeOf(xhr, prototype);
return xhr;
};
Object.assign(window.XMLHttpRequest, win.CapacitorWebXMLHttpRequest.fullObject);
}
}
// patch window.console on iOS and store original console fns
Expand Down
6 changes: 6 additions & 0 deletions core/native-bridge.ts
Expand Up @@ -434,6 +434,7 @@ const initBridge = (w: any): void => {
win.CapacitorWebXMLHttpRequest = {
abort: window.XMLHttpRequest.prototype.abort,
constructor: window.XMLHttpRequest.prototype.constructor,
fullObject: window.XMLHttpRequest,
getAllResponseHeaders:
window.XMLHttpRequest.prototype.getAllResponseHeaders,
getResponseHeader: window.XMLHttpRequest.prototype.getResponseHeader,
Expand Down Expand Up @@ -798,6 +799,11 @@ const initBridge = (w: any): void => {
Object.setPrototypeOf(xhr, prototype);
return xhr;
} as unknown as PatchedXMLHttpRequestConstructor;

Object.assign(
window.XMLHttpRequest,
win.CapacitorWebXMLHttpRequest.fullObject,
);
}
}

Expand Down
2 changes: 2 additions & 0 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Expand Up @@ -394,6 +394,7 @@ var nativeBridge = (function (exports) {
win.CapacitorWebXMLHttpRequest = {
abort: window.XMLHttpRequest.prototype.abort,
constructor: window.XMLHttpRequest.prototype.constructor,
fullObject: window.XMLHttpRequest,
getAllResponseHeaders: window.XMLHttpRequest.prototype.getAllResponseHeaders,
getResponseHeader: window.XMLHttpRequest.prototype.getResponseHeader,
open: window.XMLHttpRequest.prototype.open,
Expand Down Expand Up @@ -674,6 +675,7 @@ var nativeBridge = (function (exports) {
Object.setPrototypeOf(xhr, prototype);
return xhr;
};
Object.assign(window.XMLHttpRequest, win.CapacitorWebXMLHttpRequest.fullObject);
}
}
// patch window.console on iOS and store original console fns
Expand Down

0 comments on commit 5cd3b2f

Please sign in to comment.