Skip to content

Commit

Permalink
fix #57
Browse files Browse the repository at this point in the history
  • Loading branch information
wendux committed Jun 14, 2022
1 parent 505806a commit 9efea44
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion dist/ajaxhook.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports.unHook = unHook;
*/

// Save original XMLHttpRequest as _rxhr
var realXhr = "_rxhr";
var realXhr = "__xhr";

var events = exports.events = ['load', 'loadend', 'timeout', 'error', 'readystatechange', 'abort'];

Expand Down
2 changes: 1 addition & 1 deletion dist/ajaxhook.core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ajaxhook.core.min.js.map

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions dist/ajaxhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports.unHook = unHook;
*/

// Save original XMLHttpRequest as _rxhr
var realXhr = "_rxhr";
var realXhr = "__xhr";

var events = exports.events = ['load', 'loadend', 'timeout', 'error', 'readystatechange', 'abort'];

Expand Down Expand Up @@ -233,16 +233,15 @@ var eventLoad = _xhrHook.events[0],
* source code: https://github.com/wendux/Ajax-hook
*/

var singleton,
prototype = 'prototype';
var prototype = 'prototype';

function proxy(proxy, win) {
if (singleton) throw "Proxy already exists";
return singleton = new Proxy(proxy, win);
win = win || window;
if (win['__xhr']) throw "Ajax is already hooked.";
return proxyAjax(proxy, win);
}

function unProxy(win) {
singleton = null;
(0, _xhrHook.unHook)(win);
}

Expand Down Expand Up @@ -324,7 +323,7 @@ var ErrorHandler = makeHandler(function (error) {
this.reject(error);
});

function Proxy(proxy, win) {
function proxyAjax(proxy, win) {
var onRequest = proxy.onRequest,
onResponse = proxy.onResponse,
onError = proxy.onError;
Expand Down
2 changes: 1 addition & 1 deletion dist/ajaxhook.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ajaxhook.min.js.map

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions dist/ajaxhook.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ exports.unHook = unHook;
*/

// Save original XMLHttpRequest as _rxhr
var realXhr = "_rxhr";
var realXhr = "__xhr";

var events = exports.events = ['load', 'loadend', 'timeout', 'error', 'readystatechange', 'abort'];

Expand Down Expand Up @@ -243,16 +243,15 @@ var eventLoad = _xhrHook.events[0],
* source code: https://github.com/wendux/Ajax-hook
*/

var singleton,
prototype = 'prototype';
var prototype = 'prototype';

function proxy(proxy, win) {
if (singleton) throw "Proxy already exists";
return singleton = new Proxy(proxy, win);
win = win || window;
if (win['__xhr']) throw "Ajax is already hooked.";
return proxyAjax(proxy, win);
}

function unProxy(win) {
singleton = null;
(0, _xhrHook.unHook)(win);
}

Expand Down Expand Up @@ -334,7 +333,7 @@ var ErrorHandler = makeHandler(function (error) {
this.reject(error);
});

function Proxy(proxy, win) {
function proxyAjax(proxy, win) {
var onRequest = proxy.onRequest,
onResponse = proxy.onResponse,
onError = proxy.onError;
Expand Down
Loading

0 comments on commit 9efea44

Please sign in to comment.