0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Fix collapse multiple ids target (#38989)

This commit is contained in:
Louis-Maxime Piton 2023-09-13 09:30:32 +02:00 committed by GitHub
parent d1d49ffe1d
commit 9900cf33c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -26,10 +26,10 @@ const getSelector = element => {
hrefAttribute = `#${hrefAttribute.split('#')[1]}`
}
selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null
selector = hrefAttribute && hrefAttribute !== '#' ? parseSelector(hrefAttribute.trim()) : null
}
return parseSelector(selector)
return selector
}
const SelectorEngine = {

View File

@ -359,6 +359,18 @@ describe('SelectorEngine', () => {
expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
})
it('should get elements if several ids are given', () => {
fixtureEl.innerHTML = [
'<div id="test" data-bs-target="#target1,#target2"></div>',
'<div class="target" id="target1"></div>',
'<div class="target" id="target2"></div>'
].join('')
const testEl = fixtureEl.querySelector('#test')
expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
})
it('should get elements in array, from href if no data-bs-target set', () => {
fixtureEl.innerHTML = [
'<a id="test" href=".target"></a>',