-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old IE polyfill code (#10238)
* Upgrade DOM Fixtures Upgrade to react-scripts v1 and include required polyfills for older browsers * Remove ChangeEvent polyfills for unsupported browsers
- Loading branch information
Showing
21 changed files
with
191 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/dom/src/components/fixtures/number-inputs/NumberInputDecimal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/dom/src/components/fixtures/number-inputs/NumberInputExtraZeroes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/dom/src/components/fixtures/number-inputs/NumberTestCase.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/dom/src/components/fixtures/password-inputs/PasswordTestCase.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
fixtures/dom/src/components/fixtures/password-inputs/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
fixtures/dom/src/components/fixtures/text-inputs/InputTestCase.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
const React = window.React; | ||
const ReactDOM = window.ReactDOM; | ||
import App from './components/App'; | ||
import './polyfills'; | ||
import loadReact from './react-loader'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
loadReact().then(() => import('./components/App')).then(App => { | ||
const {React, ReactDOM} = window; | ||
|
||
ReactDOM.render( | ||
React.createElement(App.default), | ||
document.getElementById('root') | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'core-js/es6/promise'; | ||
import 'core-js/es6/set'; | ||
import 'core-js/es6/map'; | ||
|
||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | ||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | ||
|
||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | ||
// MIT license | ||
(function() { | ||
var lastTime = 0; | ||
var vendors = ['ms', 'moz', 'webkit', 'o']; | ||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { | ||
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; | ||
window.cancelAnimationFrame = | ||
window[vendors[x] + 'CancelAnimationFrame'] || | ||
window[vendors[x] + 'CancelRequestAnimationFrame']; | ||
} | ||
|
||
if (!window.requestAnimationFrame) | ||
window.requestAnimationFrame = function(callback, element) { | ||
var currTime = new Date().getTime(); | ||
var timeToCall = Math.max(0, 16 - (currTime - lastTime)); | ||
var id = window.setTimeout(function() { | ||
callback(currTime + timeToCall); | ||
}, timeToCall); | ||
lastTime = currTime + timeToCall; | ||
return id; | ||
}; | ||
|
||
if (!window.cancelAnimationFrame) | ||
window.cancelAnimationFrame = function(id) { | ||
clearTimeout(id); | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Take a version from the window query string and load a specific | ||
* version of React. | ||
* | ||
* @example | ||
* http://localhost:3000?version=15.4.1 | ||
* (Loads React 15.4.1) | ||
*/ | ||
|
||
function parseQuery(qstr) { | ||
var query = {}; | ||
var a = qstr.substr(1).split('&'); | ||
|
||
for (var i = 0; i < a.length; i++) { | ||
var b = a[i].split('='); | ||
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || ''); | ||
} | ||
return query; | ||
} | ||
|
||
function loadScript(src) { | ||
let firstScript = document.getElementsByTagName('script')[0]; | ||
let scriptNode; | ||
|
||
return new Promise((resolve, reject) => { | ||
scriptNode = document.createElement('script'); | ||
scriptNode.async = 1; | ||
scriptNode.src = src; | ||
|
||
scriptNode.onload = () => resolve(); | ||
scriptNode.onerror = () => reject(new Error(`failed to load: ${src}`)); | ||
|
||
firstScript.parentNode.insertBefore(scriptNode, firstScript); | ||
}); | ||
} | ||
|
||
export default function loadReact() { | ||
let REACT_PATH = 'react.development.js'; | ||
let DOM_PATH = 'react-dom.development.js'; | ||
|
||
let query = parseQuery(window.location.search); | ||
let version = query.version || 'local'; | ||
|
||
if (version !== 'local') { | ||
REACT_PATH = 'https://unpkg.com/react@' + version + '/dist/react.js'; | ||
DOM_PATH = 'https://unpkg.com/react-dom@' + version + '/dist/react-dom.js'; | ||
} | ||
|
||
const needsReactDOM = version === 'local' || parseFloat(version, 10) > 0.13; | ||
|
||
let request = loadScript(REACT_PATH); | ||
|
||
if (needsReactDOM) { | ||
request = request.then(() => loadScript(DOM_PATH)); | ||
} else { | ||
// Aliasing React to ReactDOM for compatibility. | ||
request = request.then(() => { | ||
window.ReactDOM = window.React; | ||
}); | ||
} | ||
|
||
return request; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.