Compare commits

..

2 Commits

Author SHA1 Message Date
Mark Otto b047a3282a Undo some 2026-01-06 20:20:40 -08:00
Mark Otto bba91a4cab Fix some JS todos and warnings 2026-01-06 16:00:22 -08:00
7 changed files with 30 additions and 67 deletions
+2 -4
View File
@@ -76,7 +76,7 @@ const Default = {
}
const DefaultType = {
interval: '(number|boolean)', // TODO:v6 remove boolean support
interval: 'number',
keyboard: 'boolean',
pause: '(string|boolean)',
ride: '(boolean|string)',
@@ -125,10 +125,9 @@ class Carousel extends BaseComponent {
}
nextWhenVisible() {
// FIXME TODO use `document.visibilityState`
// Don't call next when the page isn't visible
// or the carousel or its parent isn't visible
if (!document.hidden && isVisible(this._element)) {
if (document.visibilityState === 'visible' && isVisible(this._element)) {
this.next()
}
}
@@ -328,7 +327,6 @@ class Carousel extends BaseComponent {
if (!activeElement || !nextElement) {
// Some weirdness is happening, so we bail
// TODO: change tests that use empty divs to avoid this check
return
}
-1
View File
@@ -126,7 +126,6 @@ function findHandler(events, callable, delegationSelector = null) {
function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
const isDelegated = typeof handler === 'string'
// TODO: tooltip passes `false` instead of selector, so we need to check
const callable = isDelegated ? delegationFunction : (handler || delegationFunction)
let typeEvent = getTypeEvent(originalTypeEvent)
+1
View File
@@ -70,6 +70,7 @@ const SelectorEngine = {
return []
},
// TODO: this is now unused; remove later along with prev()
next(element, selector) {
let next = element.nextElementSibling
-6
View File
@@ -39,7 +39,6 @@ const SELECTOR_DROPDOWN = '.dropdown'
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
const Default = {
offset: null, // TODO: v6 @deprecated, keep it for backwards compatibility reasons
rootMargin: '0px 0px -25%',
smoothScroll: false,
target: null,
@@ -47,7 +46,6 @@ const Default = {
}
const DefaultType = {
offset: '(number|null)', // TODO v6 @deprecated, keep it for backwards compatibility reasons
rootMargin: 'string',
smoothScroll: 'boolean',
target: 'element',
@@ -111,12 +109,8 @@ class ScrollSpy extends BaseComponent {
// Private
_configAfterMerge(config) {
// TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
config.target = getElement(config.target) || document.body
// TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin
if (typeof config.threshold === 'string') {
config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value))
}
+1 -1
View File
@@ -62,7 +62,7 @@ class Tab extends BaseComponent {
if (!this._parent) {
return
// TODO: should throw exception in v6
// throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
// throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_TAB_PANEL}`)
}
// Set up initial aria attributes
-6
View File
@@ -320,13 +320,7 @@ class Tooltip extends BaseComponent {
_createTipElement(content) {
const tip = this._getTemplateFactory(content).toHtml()
// TODO: remove this check in v6
if (!tip) {
return null
}
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW)
// TODO: v6 the following can be achieved with CSS only
tip.classList.add(`bs-${this.constructor.NAME}-auto`)
const tipId = getUID(this.constructor.NAME).toString()
+26 -49
View File
@@ -59,60 +59,37 @@ describe('Dropdown', () => {
expect(dropdownByElement._element).toEqual(btnDropdown)
})
it('should work on invalid markup', () => {
return new Promise(resolve => {
// TODO: REMOVE in v6
fixtureEl.innerHTML = [
'<div class="dropdown">',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Link</a>',
' </div>',
'</div>'
].join('')
it('should create offset modifier correctly when offset option is a function', async () => {
fixtureEl.innerHTML = [
'<div class="dropdown">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Secondary link</a>',
' </div>',
'</div>'
].join('')
const dropdownElem = fixtureEl.querySelector('.dropdown-menu')
const dropdown = new Dropdown(dropdownElem)
dropdownElem.addEventListener('shown.bs.dropdown', () => {
resolve()
})
expect().nothing()
dropdown.show()
const getOffset = jasmine.createSpy('getOffset').and.returnValue([10, 20])
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
const dropdown = new Dropdown(btnDropdown, {
offset: getOffset
})
})
it('should create offset modifier correctly when offset option is a function', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [
'<div class="dropdown">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Secondary link</a>',
' </div>',
'</div>'
].join('')
const offset = dropdown._getOffset()
expect(typeof offset).toEqual('function')
const getOffset = jasmine.createSpy('getOffset').and.returnValue([10, 20])
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
const dropdown = new Dropdown(btnDropdown, {
offset: getOffset
})
btnDropdown.addEventListener('shown.bs.dropdown', () => {
// Floating UI calls offset function asynchronously
setTimeout(() => {
expect(getOffset).toHaveBeenCalled()
resolve()
}, 20)
})
const offset = dropdown._getOffset()
expect(typeof offset).toEqual('function')
dropdown.show()
const shownPromise = new Promise(resolve => {
btnDropdown.addEventListener('shown.bs.dropdown', resolve)
})
dropdown.show()
await shownPromise
// Floating UI calls offset function asynchronously
await new Promise(resolve => {
setTimeout(resolve, 20)
})
expect(getOffset).toHaveBeenCalled()
})
it('should create offset modifier correctly when offset option is a string into data attribute', () => {