From b2bc159d722a640b684f12a1171d70c8d5284b4e Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Sat, 27 Mar 2021 21:38:45 +0530 Subject: [PATCH] Use cached `noop` function everywhere --- js/src/dropdown.js | 6 +++--- js/src/tooltip.js | 2 +- js/src/util/index.js | 2 +- js/tests/unit/util/index.spec.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 6b541ed150..3e1ef5fd4f 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -192,7 +192,7 @@ class Dropdown extends BaseComponent { if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) { [].concat(...document.body.children) - .forEach(elem => EventHandler.on(elem, 'mouseover', null, noop())) + .forEach(elem => EventHandler.on(elem, 'mouseover', null, noop)) } this._element.focus() @@ -222,7 +222,7 @@ class Dropdown extends BaseComponent { // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { [].concat(...document.body.children) - .forEach(elem => EventHandler.off(elem, 'mouseover', null, noop())) + .forEach(elem => EventHandler.off(elem, 'mouseover', null, noop)) } if (this._popper) { @@ -435,7 +435,7 @@ class Dropdown extends BaseComponent { // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { [].concat(...document.body.children) - .forEach(elem => EventHandler.off(elem, 'mouseover', null, noop())) + .forEach(elem => EventHandler.off(elem, 'mouseover', null, noop)) } if (context._popper) { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 4fea1c9646..a66e1ad41e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -301,7 +301,7 @@ class Tooltip extends BaseComponent { // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html if ('ontouchstart' in document.documentElement) { [].concat(...document.body.children).forEach(element => { - EventHandler.on(element, 'mouseover', noop()) + EventHandler.on(element, 'mouseover', noop) }) } diff --git a/js/src/util/index.js b/js/src/util/index.js index cc35d8a37c..f19d76e036 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -190,7 +190,7 @@ const findShadowRoot = element => { return findShadowRoot(element.parentNode) } -const noop = () => function () {} +const noop = () => {} const reflow = element => element.offsetHeight diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index 41c1ce2b80..5d144348e4 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -477,8 +477,8 @@ describe('Util', () => { }) describe('noop', () => { - it('should return a function', () => { - expect(typeof Util.noop()).toEqual('function') + it('should be a function', () => { + expect(typeof Util.noop).toEqual('function') }) }) -- 2.47.2