diff --git a/src/client/core/utils/array.js b/src/client/core/utils/array.js index 2c673dc57e..75822fa46c 100644 --- a/src/client/core/utils/array.js +++ b/src/client/core/utils/array.js @@ -28,32 +28,11 @@ export function isArray (arg) { } export function from (arg, ...args) { - if (nativeMethods.arrayFrom) - return nativeMethods.arrayFrom(arg, ...args); - - // NOTE: this logic is for IE - const arr = []; - const length = arg.length; - - for (let i = 0; i < length; i++) - arr.push(arg[i]); - - return arr; + return nativeMethods.arrayFrom(arg, ...args); } export function find (arr, callback) { - if (nativeMethods.arrayFind) - return nativeMethods.arrayFind.call(arr, callback); - - // NOTE: this logic is for IE - const length = arr.length; - - for (let i = 0; i < length; i++) { - if (callback(arr[i], i, arr)) - return arr[i]; - } - - return null; + return nativeMethods.arrayFind.call(arr, callback); } export function remove (arr, item) { diff --git a/src/client/core/utils/content-editable.js b/src/client/core/utils/content-editable.js index 7590521e38..46dfb13bd9 100644 --- a/src/client/core/utils/content-editable.js +++ b/src/client/core/utils/content-editable.js @@ -285,23 +285,15 @@ export function getNearestCommonAncestor (node1, node2) { //selection utils function getSelectedPositionInParentByOffset (node, offset) { - let currentNode = null; - let currentOffset = null; - const childNodes = nativeMethods.nodeChildNodesGetter.call(node); - const childCount = domUtils.getChildNodesLength(childNodes); - let isSearchForLastChild = offset >= childCount; - // NOTE: we get a child element by its offset index in the parent if (domUtils.isShadowUIElement(node)) return { node, offset }; - // NOTE: IE behavior - if (isSearchForLastChild) - currentNode = childNodes[childCount - 1]; - else { - currentNode = childNodes[offset]; - currentOffset = 0; - } + const childNodes = nativeMethods.nodeChildNodesGetter.call(node); + const childCount = domUtils.getChildNodesLength(childNodes); + let isSearchForLastChild = offset >= childCount; + let currentNode = childNodes[offset]; + let currentOffset = 0; // NOTE: skip shadowUI elements if (domUtils.isShadowUIElement(currentNode)) { diff --git a/src/client/core/utils/event-emitter.ts b/src/client/core/utils/event-emitter.ts index 85a5cdfeb0..25cba4919d 100644 --- a/src/client/core/utils/event-emitter.ts +++ b/src/client/core/utils/event-emitter.ts @@ -47,19 +47,7 @@ export default class EventEmitter { if (!listeners) return; - for (let i = 0; i < listeners.length; i++) { - try { - listeners[i].apply(this, args); - } - catch (e: any) { - // Hack for IE: after document.write calling IFrameSandbox event handlers - // rises 'Can't execute code from a freed script' exception because document has been - // recreated - if (e.message && e.message.indexOf('freed script') > -1) - this.off(evt, listeners[i]); - else - throw e; - } - } + for (let i = 0; i < listeners.length; i++) + listeners[i].apply(this, args); } } diff --git a/src/client/core/utils/event.js b/src/client/core/utils/event.js index 1ad8e88f6c..55b0f0cafa 100644 --- a/src/client/core/utils/event.js +++ b/src/client/core/utils/event.js @@ -6,7 +6,6 @@ import * as domUtils from './dom'; const Promise = hammerhead.Promise; const nativeMethods = hammerhead.nativeMethods; const listeners = hammerhead.eventSandbox.listeners; -const browserUtils = hammerhead.utils.browser; // Imported form the hammerhead export const BUTTON = hammerhead.utils.event.BUTTON; @@ -17,17 +16,11 @@ export const WHICH_PARAMETER = hammerhead.utils.event.WHICH_PARAMETER; export const preventDefault = hammerhead.utils.event.preventDefault; export function bind (el, event, handler, useCapture) { - if (browserUtils.isIE11 && domUtils.isWindow(el)) - nativeMethods.windowAddEventListener.call(el, event, handler, useCapture); - else - nativeMethods.addEventListener.call(el, event, handler, useCapture); + nativeMethods.addEventListener.call(el, event, handler, useCapture); } export function unbind (el, event, handler, useCapture) { - if (browserUtils.isIE11 && domUtils.isWindow(el)) - nativeMethods.windowRemoveEventListener.call(el, event, handler, useCapture); - else - nativeMethods.removeEventListener.call(el, event, handler, useCapture); + nativeMethods.removeEventListener.call(el, event, handler, useCapture); }