XDomainRequest. IE 8 will not work when CORS requests
- Ngôn ngữ chính
- JavaScript
- Star
- 5.7k
- Fork
- 204
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
## steps to reproduce
unfetch@4.0.1:
```html
fetch('page2.html')
.then(function(response) {
return response.text();
})
.then(function(data) {
console.log(data);
});
... any data ...
```
use any http server that supports Access-Control-Allow-Origin headers:
```bash
npm install http-server -g
http-server -p 8081 --cors
```
* --cors - to enable CORS via the Access-Control-Allow-Origin
### result
Through VM WinXP SP3 with **IE version: 8.0.6001.18702** Update version: 0
* F12 - Document Mode = 8 and 7.
and/or
* Win10 IE11 - F12 - Emulation - Document Mode = 7 and 8 / User agent: 7/8
**It does not work at all!**
## user-space solutions
Here's my example of hack for already released unfetch version like 4.0.1. Works fine for IE7+:
```javascript
var send = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function()
{
this.onreadystatechange = function()
{
// TODO: prevent duplicate calling of onload if it's not CORS!
if(this.readyState === 4 && this.status === 200) {
return this.onload.apply(this, arguments);
}
}
return send.apply(this, arguments);
}
// IE7+ ok now
```
Actually, even IE 11 with 5+ emulation, that of course strange :) because it should be ActiveXObject [before IE7](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6). Bad emulation :)
However, **for real IE8** CORS support we should have requests through **XDomainRequest** not for XMLHttpRequest. Thus, your `onload()` is silent.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với unfetch@4.0.1/polyfill/index.js và lần theo cách xử lý XMLHttpRequest.prototype.send và onload được mô tả trong báo cáo. Tái hiện yêu cầu CORS trong IE8 hoặc các chế độ mô phỏng IE7/8 đã được ghi lại, sau đó xác minh rằng yêu cầu đã hoàn tất gọi callback mong đợi thông qua legacy transport phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- frontend, web-dev
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100