diff options
author | Rohit Sharma <rohit2sharma95@gmail.com> | 2021-03-27 19:08:45 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-04-11 09:42:52 +0300 |
commit | b2bc159d722a640b684f12a1171d70c8d5284b4e (patch) | |
tree | 051580f72867e0595199e1368737c95da8c32e6b /js | |
parent | 7b7f4a5ced176ae3d7d9d16583795245cb9c7df3 (diff) |
Use cached `noop` function everywhere
Diffstat (limited to 'js')
-rw-r--r-- | js/src/dropdown.js | 6 | ||||
-rw-r--r-- | js/src/tooltip.js | 2 | ||||
-rw-r--r-- | js/src/util/index.js | 2 | ||||
-rw-r--r-- | 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') }) }) |