From 4aef395e49a5418b9eec849dc1eb5ab1a180db4e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 23 Aug 2017 16:28:01 +0200 Subject: [PATCH] Disable ESlint on no-return-assign and temporary for arrow-body-style --- .eslintrc.json | 1 - js/src/alert.js | 2 +- js/src/dom/selectorEngine.js | 12 ++++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bfd2d333ae..e0b3e5380a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -69,7 +69,6 @@ "no-param-reassign": "off", "no-proto": "error", "no-restricted-properties": "error", - "no-return-assign": "error", "no-return-await": "error", "no-script-url": "error", "no-self-compare": "error", diff --git a/js/src/alert.js b/js/src/alert.js index c530b2996b..000d7506f1 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -66,7 +66,7 @@ class Alert { const customEvent = this._triggerCloseEvent(rootElement) - if (customEvent.defaultPrevented) { + if (customEvent === null || customEvent.defaultPrevented) { return } diff --git a/js/src/dom/selectorEngine.js b/js/src/dom/selectorEngine.js index f6f3fe82f0..1c98c15ae1 100644 --- a/js/src/dom/selectorEngine.js +++ b/js/src/dom/selectorEngine.js @@ -16,8 +16,9 @@ if (!Element.prototype.matches) { } // closest polyfill (see: https://mzl.la/2vXggaI) +let fnClosest = null if (!Element.prototype.closest) { - Element.prototype.closest = (element, selector) => { + fnClosest = (element, selector) => { let ancestor = element if (!document.documentElement.contains(element)) { return null @@ -33,10 +34,13 @@ if (!Element.prototype.closest) { return null } +} else { + // eslint-disable-next-line arrow-body-style + fnClosest = (element, selector) => { + return element.closest(selector) + } } -const fnClosest = Element.prototype.closest - const SelectorEngine = { matches(element, selector) { return fnMatches.call(element, selector) @@ -56,7 +60,7 @@ const SelectorEngine = { }, closest(element, selector) { - return fnClosest.call(element, selector) + return fnClosest(element, selector) } }