diff options
| author | Rohit Sharma <[email protected]> | 2021-03-27 21:38:45 +0530 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2021-04-11 09:42:52 +0300 |
| commit | b2bc159d722a640b684f12a1171d70c8d5284b4e (patch) | |
| tree | 051580f72867e0595199e1368737c95da8c32e6b | |
| parent | 7b7f4a5ced176ae3d7d9d16583795245cb9c7df3 (diff) | |
| download | bootstrap-b2bc159d722a640b684f12a1171d70c8d5284b4e.tar.xz bootstrap-b2bc159d722a640b684f12a1171d70c8d5284b4e.zip | |
Use cached `noop` function everywhere
| -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 6b541ed15..3e1ef5fd4 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 4fea1c964..a66e1ad41 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 cc35d8a37..f19d76e03 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 41c1ce2b8..5d144348e 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') }) }) |
