Skip to content

Commit

Permalink
fix #49 #52
Browse files Browse the repository at this point in the history
  • Loading branch information
wendux committed May 8, 2020
1 parent 5422f31 commit b6033a2
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README-EN.md
Expand Up @@ -21,7 +21,7 @@ Hooking Javascript XMLHttpRequest ,It can intercept Ajax requests and respon
- Using cdn

```html
<script src="https://unpkg.com/ajax-hook@2.0.2/dist/ajaxhook.min.js"></script>
<script src="https://unpkg.com/ajax-hook@2.0.3/dist/ajaxhook.min.js"></script>
```

- Using npm
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -24,7 +24,7 @@ Ajax-hook是一个精巧的用于拦截浏览器XMLHttpRequest的库,它可以
- CDN引入

```html
<script src="https://unpkg.com/ajax-hook@2.0.2/dist/ajaxhook.min.js"></script>
<script src="https://unpkg.com/ajax-hook@2.0.3/dist/ajaxhook.min.js"></script>
```

引入后会有一个名为"ah"(ajax hook)的全局对象,通过它可以调用ajax-hook的API,如`ah.proxy(hooks)`
Expand Down
5 changes: 5 additions & 0 deletions change-list.md
@@ -1,5 +1,10 @@
# Change list


## 2.0.3

- 兼容IE fix #49 #52

## 2.0.2

- fix #47
Expand Down
31 changes: 26 additions & 5 deletions demon/proxy.html
Expand Up @@ -79,7 +79,7 @@
console.log('response', xhr.response)
})
//setTimeout(()=>xhr.abort(),100)
xhr.open('get', url, true);
xhr.open('get', url);
xhr.send();

}
Expand All @@ -88,15 +88,36 @@
$.get(url).done(function (d) {
console.log(d)
}).fail(function (e) {
console.log('hi world',e)
console.log('hi world', e)
})
}

//test('https://aa/');
//test('https://bb/');
testJquery('https://aa/');
testJquery('https://bb/');
testJquery(location.href)
// test(location.href+'?');
// testJquery('https://aa/');
// testJquery('https://bb/');
// testJquery(location.href)
var ca = Function.prototype.call
Function.prototype.call = function _call (a, b, c, d) {
Function.prototype.call = ca;
console.log(a,b,c,d)
ca(a,b,c,d,)
Function.prototype.call = _call;
}
function a() {
alert("xxx")
}
a()
// Function.prototype.call.call.call===Function.prototype.call.call.call.call.call
var a={};
//a.__proto__.x=a
a.x=a;
a.toJSON=function () {
return {"dd":55}
}


</script>
</body>
</html>
2 changes: 1 addition & 1 deletion dist/ajaxhook.core.min.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion dist/ajaxhook.js
Expand Up @@ -246,7 +246,15 @@ function triggerListener(xhr, name) {
var callback = 'on' + name + '_';
var event = (0, _xhrHook.configEvent)({ type: name }, xhrProxy);
xhrProxy[callback] && xhrProxy[callback](event);
getEventTarget(xhr).dispatchEvent(new Event(name, { bubbles: false }));
var evt;
if (typeof Event === 'function') {
evt = new Event(name, { bubbles: false });
} else {
// https://stackoverflow.com/questions/27176983/dispatchevent-not-working-in-ie11
evt = document.createEvent('Event');
evt.initEvent(name, false, true);
}
getEventTarget(xhr).dispatchEvent(evt);
}

function Handler(xhr) {
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.

10 changes: 9 additions & 1 deletion dist/ajaxhook.umd.js
Expand Up @@ -256,7 +256,15 @@ function triggerListener(xhr, name) {
var callback = 'on' + name + '_';
var event = (0, _xhrHook.configEvent)({ type: name }, xhrProxy);
xhrProxy[callback] && xhrProxy[callback](event);
getEventTarget(xhr).dispatchEvent(new Event(name, { bubbles: false }));
var evt;
if (typeof Event === 'function') {
evt = new Event(name, { bubbles: false });
} else {
// https://stackoverflow.com/questions/27176983/dispatchevent-not-working-in-ie11
evt = document.createEvent('Event');
evt.initEvent(name, false, true);
}
getEventTarget(xhr).dispatchEvent(evt);
}

function Handler(xhr) {
Expand Down

0 comments on commit b6033a2

Please sign in to comment.