aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/src/dom/event-handler.js20
-rw-r--r--js/src/dom/manipulator.js4
-rw-r--r--js/src/util/sanitizer.js2
-rw-r--r--js/tests/unit/collapse.spec.js8
-rw-r--r--js/tests/unit/scrollspy.spec.js2
-rw-r--r--js/tests/unit/util/index.spec.js4
-rw-r--r--js/tests/unit/util/sanitizer.spec.js1
7 files changed, 21 insertions, 20 deletions
diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js
index 9cb0583fc..8e291e76c 100644
--- a/js/src/dom/event-handler.js
+++ b/js/src/dom/event-handler.js
@@ -78,11 +78,11 @@ const nativeEvents = new Set([
* ------------------------------------------------------------------------
*/
-function getUidEvent(element, uid) {
+const getUidEvent = (element, uid) => {
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++
}
-function getEvent(element) {
+const getEvent = element => {
const uid = getUidEvent(element)
element.uidEvent = uid
@@ -91,7 +91,7 @@ function getEvent(element) {
return eventRegistry[uid]
}
-function bootstrapHandler(element, fn) {
+const bootstrapHandler = (element, fn) => {
return function handler(event) {
event.delegateTarget = element
@@ -103,7 +103,7 @@ function bootstrapHandler(element, fn) {
}
}
-function bootstrapDelegationHandler(element, selector, fn) {
+const bootstrapDelegationHandler = (element, selector, fn) => {
return function handler(event) {
const domElements = element.querySelectorAll(selector)
@@ -126,7 +126,7 @@ function bootstrapDelegationHandler(element, selector, fn) {
}
}
-function findHandler(events, handler, delegationSelector = null) {
+const findHandler = (events, handler, delegationSelector = null) => {
const uidEventList = Object.keys(events)
for (const element of uidEventList) {
@@ -140,7 +140,7 @@ function findHandler(events, handler, delegationSelector = null) {
return null
}
-function normalizeParams(originalTypeEvent, handler, delegationFn) {
+const normalizeParams = (originalTypeEvent, handler, delegationFn) => {
const delegation = typeof handler === 'string'
const originalHandler = delegation ? delegationFn : handler
@@ -154,7 +154,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) {
return [delegation, originalHandler, typeEvent]
}
-function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
+const addHandler = (element, originalTypeEvent, handler, delegationFn, oneOff) => {
if (typeof originalTypeEvent !== 'string' || !element) {
return
}
@@ -207,7 +207,7 @@ function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
element.addEventListener(typeEvent, fn, delegation)
}
-function removeHandler(element, events, typeEvent, handler, delegationSelector) {
+const removeHandler = (element, events, typeEvent, handler, delegationSelector) => {
const fn = findHandler(events[typeEvent], handler, delegationSelector)
if (!fn) {
@@ -218,7 +218,7 @@ function removeHandler(element, events, typeEvent, handler, delegationSelector)
delete events[typeEvent][fn.uidEvent]
}
-function removeNamespacedHandlers(element, events, typeEvent, namespace) {
+const removeNamespacedHandlers = (element, events, typeEvent, namespace) => {
const storeElementEvent = events[typeEvent] || {}
for (const handlerKey of Object.keys(storeElementEvent)) {
@@ -230,7 +230,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) {
}
}
-function getTypeEvent(event) {
+const getTypeEvent = event => {
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
event = event.replace(stripNameRegex, '')
return customEvents[event] || event
diff --git a/js/src/dom/manipulator.js b/js/src/dom/manipulator.js
index b9a73ee37..dece35100 100644
--- a/js/src/dom/manipulator.js
+++ b/js/src/dom/manipulator.js
@@ -5,7 +5,7 @@
* --------------------------------------------------------------------------
*/
-function normalizeData(val) {
+const normalizeData = val => {
if (val === 'true') {
return true
}
@@ -25,7 +25,7 @@ function normalizeData(val) {
return val
}
-function normalizeDataKey(key) {
+const normalizeDataKey = key => {
return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)
}
diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js
index 50199625e..a164936a7 100644
--- a/js/src/util/sanitizer.js
+++ b/js/src/util/sanitizer.js
@@ -82,7 +82,7 @@ export const DefaultAllowlist = {
ul: []
}
-export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
+export const sanitizeHtml = (unsafeHtml, allowList, sanitizeFn) => {
if (!unsafeHtml.length) {
return unsafeHtml
}
diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js
index da709bb85..082e6505f 100644
--- a/js/tests/unit/collapse.spec.js
+++ b/js/tests/unit/collapse.spec.js
@@ -734,7 +734,7 @@ describe('Collapse', () => {
two: false
}
- function firstTest() {
+ const firstTest = () => {
expect(collapseOneOne.classList.contains('show')).toEqual(true)
expect(collapseOneTwo.classList.contains('show')).toEqual(true)
@@ -744,7 +744,7 @@ describe('Collapse', () => {
triggerTwo.click()
}
- function secondTest() {
+ const secondTest = () => {
expect(collapseOneOne.classList.contains('show')).toEqual(false)
expect(collapseOneTwo.classList.contains('show')).toEqual(false)
@@ -816,7 +816,7 @@ describe('Collapse', () => {
const collapseTwo = fixtureEl.querySelector('#collapseTwo')
const nestedCollapseOne = fixtureEl.querySelector('#nestedCollapseOne')
- function handlerCollapseOne() {
+ const handlerCollapseOne = () => {
expect(collapseOne.classList.contains('show')).toEqual(true)
expect(collapseTwo.classList.contains('show')).toEqual(false)
expect(nestedCollapseOne.classList.contains('show')).toEqual(false)
@@ -826,7 +826,7 @@ describe('Collapse', () => {
collapseOne.removeEventListener('shown.bs.collapse', handlerCollapseOne)
}
- function handlerNestedCollapseOne() {
+ const handlerNestedCollapseOne = () => {
expect(collapseOne.classList.contains('show')).toEqual(true)
expect(collapseTwo.classList.contains('show')).toEqual(false)
expect(nestedCollapseOne.classList.contains('show')).toEqual(true)
diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js
index ad44d5b3c..66e4cd7bf 100644
--- a/js/tests/unit/scrollspy.spec.js
+++ b/js/tests/unit/scrollspy.spec.js
@@ -15,7 +15,7 @@ describe('ScrollSpy', () => {
const paddingTop = 5
const scrollHeight = Math.ceil(contentEl.scrollTop + Manipulator.position(target).top) + paddingTop
- function listener() {
+ const listener = () => {
expect(element.classList.contains('active')).toEqual(true)
contentEl.removeEventListener('scroll', listener)
expect(scrollSpy._process).toHaveBeenCalled()
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js
index 38e94dc6b..2563aad8f 100644
--- a/js/tests/unit/util/index.spec.js
+++ b/js/tests/unit/util/index.spec.js
@@ -625,9 +625,9 @@ describe('Util', () => {
})
it('should define a plugin on the jQuery instance', () => {
- const pluginMock = function () {}
+ const pluginMock = () => {}
pluginMock.NAME = 'test'
- pluginMock.jQueryInterface = function () {}
+ pluginMock.jQueryInterface = () => {}
Util.defineJQueryPlugin(pluginMock)
expect(fakejQuery.fn.test).toBe(pluginMock.jQueryInterface)
diff --git a/js/tests/unit/util/sanitizer.spec.js b/js/tests/unit/util/sanitizer.spec.js
index 7379d221f..6aa307f72 100644
--- a/js/tests/unit/util/sanitizer.spec.js
+++ b/js/tests/unit/util/sanitizer.spec.js
@@ -55,6 +55,7 @@ describe('Sanitizer', () => {
'</div>'
].join('')
+ // eslint-disable-next-line func-style
function mySanitize(htmlUnsafe) {
return htmlUnsafe
}