Fetch the repository succeeded.
简体中文 | English
This solution will show you how to use React
stack in IE8, then you don't have to change the technology stack when the customer uses legacy browser. It uses ES6, Webpack, Babel, ESLint, Ant Design 1.x, React 16, Reach, Rematch, etc. See Reactie Todo.
Choose the shims and polyfills you need.
console.log()
etc always;Proxy
polyfill based on ES3 supports IE8, Node.js, etc;Promise
;Promise
library with unmatched performance;window.fetch
JavaScript polyfill supporting IE8;fetch
polyfill which supports all mainstream browsers, even IE6, IE7, IE8;Object.defineProperty
: It can't be emulated in IE8, you must not use this method;Object.defineProperty
, the preset @babel/preset-env
should be configured as follows;{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
loose: true,
modules: 'commonjs',
}]
]
}
}
// Config
[
new UglifyJsPlugin({
uglifyOptions: {
ie8: true,
...
}
})
]
// Before
var obj = { default: 1 };
// After
var obj = { "default": 1 };
import
or require
certain modules more easily, for example using anujs
instead of React
.// Config
{
resolve: {
alias: {
'react': 'anujs/dist/ReactIE',
'react-dom': 'anujs/dist/ReactIE',
...
}
}
}
// Code
import React from 'react'; // `anujs` was loaded, actually
Error | Reason | Resolve |
---|---|---|
'JSON' is undefined |
Need to use IE8 Standards Mode | Add <!DOCTYPE html> and <meta http-equiv="X-UA-Compatible" content="IE=EDGE"/>
|
无法获取未定义或 null 引用的属性“appendChild” |
document.head isn't exist in IE8 |
Add document.head = document.getElementsByTagName('head')[0]
|
无法获取未定义或 null 引用的属性“focus” , happen in this.calendarInstance.focus() (Use antd 1.11.6) |
calendarInstance is undefined, caused by this.saveCalendarRef = refFn.bind(this, 'calendarInstance')
|
Use this.saveCalendarRef = refFn.bind(this, 'calendarInstance', this)
|
Object.prototype.propertyIsEnumerable: 'this' 不是 JavaScript 对象 , happen in the function getLocation of Reach (Use anujs 1.4.8) |
After transforming by Babel, getLocation uses Object.prototype.propertyIsEnumerable.call(location, prop) to judge whether window.location has certain properties, and it doesn't work in IE8 |
See anujs issue #344 |
Accessors not supported! |
Your code is transformed into Object.defineProperty .For example, Redux uses a library symbol-observable , which is transformed into Object.defineProperty
|
Find it, and change it. I have rewritten the library symbol-observable |
IE8 sinks into endless loop, happen in the function isPlainObject of Redux |
isPlainObject uses the function getPrototypeOf of es5-shim to traverse the prototype chain, that causes endless loop |
See es5-shim issue #458 |
Sign in for post a comment
Activity
Community
Health
Trend
Influence
:Code submit frequency
:React/respond to issue & PR etc.
:Well-balanced team members and collaboration
:Recent popularity of project
:Star counts, download counts etc.
Comments ( 9 )