developit / developit/unfetch

XDomainRequest. IE 8 will not work when CORS requests

オープン
#106 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
possible-addon
主要言語
JavaScript
スター
5.7k
フォーク
204
PR マージ指標
30日以内にマージされた PR はありません

説明

## 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

unfetch@4.0.1/polyfill/index.js から始め、レポートで説明されている XMLHttpRequest.prototype.send と onload の処理を追跡します。IE8 または文書化されている IE7/8 エミュレーションモードで CORS リクエストを再現し、完了したリクエストが適切な legacy transport を通じて期待される callback を呼び出すことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
frontend, web-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。