Skip to content

Commit

Permalink
Add polyfill for NodeList#forEach in IE11 to enable querySelectorAll …
Browse files Browse the repository at this point in the history
…iteration
  • Loading branch information
kevinrobinson committed May 29, 2019
1 parent 54b4ce5 commit 0623c26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/index.js
Expand Up @@ -16,11 +16,11 @@ if (!$('body').hasClass('educator-signed-in')) {
// Make searchbar interactive, and grab any text the user already typed
// in the placeholder <input />
document.querySelectorAll('.NavbarSignedIn-StudentSearchbar').forEach(el => {
const initialText = document.querySelector('.NavbarSignedIn-StudentSearchbar-placeholder').value || '';
const placeholderEl = document.querySelector('.NavbarSignedIn-StudentSearchbar-placeholder');
const initialText = (placeholderEl && placeholderEl.value) || '';
ReactDOM.render(<StudentSearchbar initialText={initialText} />, el);
});


// Routing
// Some pages are server-rendered and have a different structure
// other than #main so we ignore those. Newer pages
Expand Down
7 changes: 7 additions & 0 deletions ui/polyfills.js
Expand Up @@ -24,6 +24,13 @@ import 'array.prototype.fill';
import ArrayFindPolyfill from 'array.prototype.find';
ArrayFindPolyfill.shim();

// Polyfill NodeList#forEach for IE11, to
// support document.querySelectorAll(selector).forEach.
// see https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}

// For React 16 in IE
// see https://reactjs.org/docs/javascript-environment-requirements.html
import 'core-js/es6/map';
Expand Down

0 comments on commit 0623c26

Please sign in to comment.