diff --git a/src/index.jsx b/src/index.jsx index f26201f..c327fdc 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -15,6 +15,24 @@ import messages from './i18n'; import './index.scss'; import App from './components/App'; +/* + ARCH-904 + Attempts to protect against browser extension manipulation of the DOM which + causes React to break. See the following link: + https://github.com/facebook/react/issues/11538#issuecomment-417504600 +*/ +if (typeof Node === 'function' && Node.prototype) { + const originalInsertBefore = Node.prototype.insertBefore; + // eslint-disable-next-line func-names + Node.prototype.insertBefore = function (newNode, referenceNode) { + if (referenceNode && referenceNode.parentNode !== this) { + NewRelicLoggingService.logError(`Cannot insert before a reference node from a different parent: ${newNode} ${referenceNode} ${this}`); + return newNode; + } + return originalInsertBefore.apply(this, arguments); // eslint-disable-line prefer-rest-params + }; +} + const apiClient = getAuthenticatedAPIClient({ appBaseUrl: configuration.BASE_URL, authBaseUrl: configuration.LMS_BASE_URL, @@ -57,30 +75,10 @@ function configure() { }; } -/* - ARCH-904 - Attempts to protect against browser extension manipulation of the DOM which - causes React to break. See the following link: - https://github.com/facebook/react/issues/11538#issuecomment-417504600 -*/ -function monkeyPatchDOMManipulation() { - if (typeof Node === 'function' && Node.prototype) { - const originalInsertBefore = Node.prototype.insertBefore; - Node.prototype.insertBefore = function (newNode, referenceNode, ...args) { - if (referenceNode && referenceNode.parentNode !== this) { - NewRelicLoggingService.logError(`Cannot insert before a reference node from a different parent: ${referenceNode} ${this}`); - return newNode; - } - return originalInsertBefore.apply(this, [newNode, referenceNode, ...args]); - }; - } -} - apiClient.ensurePublicOrAuthenticationAndCookies( window.location.pathname, () => { const { store, history } = configure(); - monkeyPatchDOMManipulation(); ReactDOM.render(, document.getElementById('root'));