diff options
author | XhmikosR <xhmikosr@gmail.com> | 2021-09-15 14:27:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 14:27:46 +0300 |
commit | c5d03d93fca6288af8d2079d8fb80cd1c606ab52 (patch) | |
tree | 8edf020f26acdc12f7be953490fbddf3e6b2b46b | |
parent | 1d484b573756adf43c5d6341477a3ae7a376615f (diff) |
Rename `e` to `event` (#34979)
-rw-r--r-- | js/src/carousel.js | 2 | ||||
-rw-r--r-- | js/tests/helpers/fixture.js | 6 | ||||
-rw-r--r-- | js/tests/unit/carousel.spec.js | 36 | ||||
-rw-r--r-- | js/tests/unit/collapse.spec.js | 8 | ||||
-rw-r--r-- | js/tests/unit/dropdown.spec.js | 28 | ||||
-rw-r--r-- | js/tests/unit/modal.spec.js | 28 | ||||
-rw-r--r-- | js/tests/unit/offcanvas.spec.js | 8 | ||||
-rw-r--r-- | site/assets/js/application.js | 22 |
8 files changed, 69 insertions, 69 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index 981ce561b6..86daa0795b 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -305,7 +305,7 @@ class Carousel extends BaseComponent { } SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => { - EventHandler.on(itemImg, EVENT_DRAG_START, e => e.preventDefault()) + EventHandler.on(itemImg, EVENT_DRAG_START, event => event.preventDefault()) }) if (this._pointerEvent) { diff --git a/js/tests/helpers/fixture.js b/js/tests/helpers/fixture.js index 2ce1081fcc..29fa91896a 100644 --- a/js/tests/helpers/fixture.js +++ b/js/tests/helpers/fixture.js @@ -24,10 +24,10 @@ export const clearFixture = () => { } export const createEvent = (eventName, params = {}) => { - const e = document.createEvent('Event') + const event = document.createEvent('Event') - e.initEvent(eventName, Boolean(params.bubbles), Boolean(params.cancelable)) - return e + event.initEvent(eventName, Boolean(params.bubbles), Boolean(params.cancelable)) + return event } export const jQueryMock = { diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js index a933f1edab..83ba289127 100644 --- a/js/tests/unit/carousel.spec.js +++ b/js/tests/unit/carousel.spec.js @@ -240,7 +240,7 @@ describe('Carousel', () => { return carouselEl.querySelector('.carousel-item.active').getAttribute('id') } - carouselEl.addEventListener('slid.bs.carousel', e => { + carouselEl.addEventListener('slid.bs.carousel', event => { const activeId = getActiveId() if (activeId === 'two') { @@ -256,7 +256,7 @@ describe('Carousel', () => { if (activeId === 'one') { // carousel wrapped around and slid from 3rd to 1st slide expect(activeId).toEqual('one') - expect(e.from + 1).toEqual(3) + expect(event.from + 1).toEqual(3) done() } }) @@ -637,8 +637,8 @@ describe('Carousel', () => { }, 20) } - carouselEl.addEventListener('slide.bs.carousel', e => { - e.preventDefault() + carouselEl.addEventListener('slide.bs.carousel', event => { + event.preventDefault() doneTest() }) @@ -663,11 +663,11 @@ describe('Carousel', () => { const carouselEl = fixtureEl.querySelector('#myCarousel') const carousel = new Carousel(carouselEl, {}) - const onSlide = e => { - expect(e.direction).toEqual('left') - expect(e.relatedTarget.classList.contains('carousel-item')).toEqual(true) - expect(e.from).toEqual(0) - expect(e.to).toEqual(1) + const onSlide = event => { + expect(event.direction).toEqual('left') + expect(event.relatedTarget.classList.contains('carousel-item')).toEqual(true) + expect(event.from).toEqual(0) + expect(event.to).toEqual(1) carouselEl.removeEventListener('slide.bs.carousel', onSlide) carouselEl.addEventListener('slide.bs.carousel', onSlide2) @@ -675,8 +675,8 @@ describe('Carousel', () => { carousel.prev() } - const onSlide2 = e => { - expect(e.direction).toEqual('right') + const onSlide2 = event => { + expect(event.direction).toEqual('right') done() } @@ -698,11 +698,11 @@ describe('Carousel', () => { const carouselEl = fixtureEl.querySelector('#myCarousel') const carousel = new Carousel(carouselEl, {}) - const onSlid = e => { - expect(e.direction).toEqual('left') - expect(e.relatedTarget.classList.contains('carousel-item')).toEqual(true) - expect(e.from).toEqual(0) - expect(e.to).toEqual(1) + const onSlid = event => { + expect(event.direction).toEqual('left') + expect(event.relatedTarget.classList.contains('carousel-item')).toEqual(true) + expect(event.from).toEqual(0) + expect(event.to).toEqual(1) carouselEl.removeEventListener('slid.bs.carousel', onSlid) carouselEl.addEventListener('slid.bs.carousel', onSlid2) @@ -710,8 +710,8 @@ describe('Carousel', () => { carousel.prev() } - const onSlid2 = e => { - expect(e.direction).toEqual('right') + const onSlid2 = event => { + expect(event.direction).toEqual('right') done() } diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index e37e37e557..82cd5c1f76 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -331,8 +331,8 @@ describe('Collapse', () => { }, 10) } - collapseEl.addEventListener('show.bs.collapse', e => { - e.preventDefault() + collapseEl.addEventListener('show.bs.collapse', event => { + event.preventDefault() expectEnd() }) @@ -408,8 +408,8 @@ describe('Collapse', () => { }, 10) } - collapseEl.addEventListener('hide.bs.collapse', e => { - e.preventDefault() + collapseEl.addEventListener('hide.bs.collapse', event => { + event.preventDefault() expectEnd() }) diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js index 2b6d8cd781..a3c60ff65b 100644 --- a/js/tests/unit/dropdown.spec.js +++ b/js/tests/unit/dropdown.spec.js @@ -576,8 +576,8 @@ describe('Dropdown', () => { const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]') const dropdown = new Dropdown(btnDropdown) - btnDropdown.addEventListener('show.bs.dropdown', e => { - e.preventDefault() + btnDropdown.addEventListener('show.bs.dropdown', event => { + event.preventDefault() }) btnDropdown.addEventListener('shown.bs.dropdown', () => { @@ -703,8 +703,8 @@ describe('Dropdown', () => { const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]') const dropdown = new Dropdown(btnDropdown) - btnDropdown.addEventListener('show.bs.dropdown', e => { - e.preventDefault() + btnDropdown.addEventListener('show.bs.dropdown', event => { + event.preventDefault() }) btnDropdown.addEventListener('shown.bs.dropdown', () => { @@ -861,8 +861,8 @@ describe('Dropdown', () => { const dropdownMenu = fixtureEl.querySelector('.dropdown-menu') const dropdown = new Dropdown(btnDropdown) - btnDropdown.addEventListener('hide.bs.dropdown', e => { - e.preventDefault() + btnDropdown.addEventListener('hide.bs.dropdown', event => { + event.preventDefault() }) btnDropdown.addEventListener('hidden.bs.dropdown', () => { @@ -1033,11 +1033,11 @@ describe('Dropdown', () => { showEventTriggered = true }) - btnDropdown.addEventListener('shown.bs.dropdown', e => setTimeout(() => { + btnDropdown.addEventListener('shown.bs.dropdown', event => setTimeout(() => { expect(btnDropdown.classList.contains('show')).toEqual(true) expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true') expect(showEventTriggered).toEqual(true) - expect(e.relatedTarget).toEqual(btnDropdown) + expect(event.relatedTarget).toEqual(btnDropdown) document.body.click() })) @@ -1045,11 +1045,11 @@ describe('Dropdown', () => { hideEventTriggered = true }) - btnDropdown.addEventListener('hidden.bs.dropdown', e => { + btnDropdown.addEventListener('hidden.bs.dropdown', event => { expect(btnDropdown.classList.contains('show')).toEqual(false) expect(btnDropdown.getAttribute('aria-expanded')).toEqual('false') expect(hideEventTriggered).toEqual(true) - expect(e.relatedTarget).toEqual(btnDropdown) + expect(event.relatedTarget).toEqual(btnDropdown) done() }) @@ -1347,12 +1347,12 @@ describe('Dropdown', () => { const triggerDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]') - triggerDropdown.addEventListener('hide.bs.dropdown', e => { - expect(e.clickEvent).toBeUndefined() + triggerDropdown.addEventListener('hide.bs.dropdown', event => { + expect(event.clickEvent).toBeUndefined() }) - triggerDropdown.addEventListener('hidden.bs.dropdown', e => { - expect(e.clickEvent).toBeUndefined() + triggerDropdown.addEventListener('hidden.bs.dropdown', event => { + expect(event.clickEvent).toBeUndefined() done() }) diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index a65ed4afa8..9632fa6cf0 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -90,8 +90,8 @@ describe('Modal', () => { const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) - modalEl.addEventListener('show.bs.modal', e => { - expect(e).toBeDefined() + modalEl.addEventListener('show.bs.modal', event => { + expect(event).toBeDefined() }) modalEl.addEventListener('shown.bs.modal', () => { @@ -114,8 +114,8 @@ describe('Modal', () => { backdrop: false }) - modalEl.addEventListener('show.bs.modal', e => { - expect(e).toBeDefined() + modalEl.addEventListener('show.bs.modal', event => { + expect(event).toBeDefined() }) modalEl.addEventListener('shown.bs.modal', () => { @@ -184,8 +184,8 @@ describe('Modal', () => { const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) - modalEl.addEventListener('show.bs.modal', e => { - e.preventDefault() + modalEl.addEventListener('show.bs.modal', event => { + event.preventDefault() const expectedDone = () => { expect().nothing() @@ -209,9 +209,9 @@ describe('Modal', () => { const modal = new Modal(modalEl) let prevented = false - modalEl.addEventListener('show.bs.modal', e => { + modalEl.addEventListener('show.bs.modal', event => { if (!prevented) { - e.preventDefault() + event.preventDefault() prevented = true setTimeout(() => { @@ -616,8 +616,8 @@ describe('Modal', () => { modal.hide() }) - modalEl.addEventListener('hide.bs.modal', e => { - expect(e).toBeDefined() + modalEl.addEventListener('hide.bs.modal', event => { + expect(event).toBeDefined() }) modalEl.addEventListener('hidden.bs.modal', () => { @@ -694,8 +694,8 @@ describe('Modal', () => { }, 10) } - modalEl.addEventListener('hide.bs.modal', e => { - e.preventDefault() + modalEl.addEventListener('hide.bs.modal', event => { + event.preventDefault() hideCallback() }) @@ -971,8 +971,8 @@ describe('Modal', () => { }, 10) } - modalEl.addEventListener('show.bs.modal', e => { - e.preventDefault() + modalEl.addEventListener('show.bs.modal', event => { + event.preventDefault() showListener() }) diff --git a/js/tests/unit/offcanvas.spec.js b/js/tests/unit/offcanvas.spec.js index ecbb710a59..877d2e7f37 100644 --- a/js/tests/unit/offcanvas.spec.js +++ b/js/tests/unit/offcanvas.spec.js @@ -316,8 +316,8 @@ describe('Offcanvas', () => { }, 10) } - offCanvasEl.addEventListener('show.bs.offcanvas', e => { - e.preventDefault() + offCanvasEl.addEventListener('show.bs.offcanvas', event => { + event.preventDefault() expectEnd() }) @@ -410,8 +410,8 @@ describe('Offcanvas', () => { }, 10) } - offCanvasEl.addEventListener('hide.bs.offcanvas', e => { - e.preventDefault() + offCanvasEl.addEventListener('hide.bs.offcanvas', event => { + event.preventDefault() expectEnd() }) diff --git a/site/assets/js/application.js b/site/assets/js/application.js index dd9162e40f..acf859764e 100644 --- a/site/assets/js/application.js +++ b/site/assets/js/application.js @@ -94,8 +94,8 @@ // Disable empty links in docs examples document.querySelectorAll('.bd-content [href="#"]') .forEach(function (link) { - link.addEventListener('click', function (e) { - e.preventDefault() + link.addEventListener('click', function (event) { + event.preventDefault() }) }) @@ -142,25 +142,25 @@ } }) - clipboard.on('success', function (e) { - var tooltipBtn = bootstrap.Tooltip.getInstance(e.trigger) + clipboard.on('success', function (event) { + var tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger) - e.trigger.setAttribute('data-bs-original-title', 'Copied!') + event.trigger.setAttribute('data-bs-original-title', 'Copied!') tooltipBtn.show() - e.trigger.setAttribute('data-bs-original-title', 'Copy to clipboard') - e.clearSelection() + event.trigger.setAttribute('data-bs-original-title', 'Copy to clipboard') + event.clearSelection() }) - clipboard.on('error', function (e) { + clipboard.on('error', function (event) { var modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-' var fallbackMsg = 'Press ' + modifierKey + 'C to copy' - var tooltipBtn = bootstrap.Tooltip.getInstance(e.trigger) + var tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger) - e.trigger.setAttribute('data-bs-original-title', fallbackMsg) + event.trigger.setAttribute('data-bs-original-title', fallbackMsg) tooltipBtn.show() - e.trigger.setAttribute('data-bs-original-title', 'Copy to clipboard') + event.trigger.setAttribute('data-bs-original-title', 'Copy to clipboard') }) anchors.options = { |