Skip to content

Commit

Permalink
Use cached noop function everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit2sharma95 authored and XhmikosR committed Apr 11, 2021
1 parent 7b7f4a5 commit b2bc159
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const findShadowRoot = element => {
return findShadowRoot(element.parentNode)
}

const noop = () => function () {}
const noop = () => {}

const reflow = element => element.offsetHeight

Expand Down
4 changes: 2 additions & 2 deletions js/tests/unit/util/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

Expand Down

0 comments on commit b2bc159

Please sign in to comment.