From 89489cd3bb06a123d07ab01255e227d288289ddb Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Tue, 1 Aug 2023 10:06:38 +0200 Subject: [PATCH 1/2] Fix collapse multiple ids --- js/src/dom/selector-engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index 3cecf6f40cfb..a47f72001bd5 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -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 = { From cbfc4a19124915b2f3803217bc949fe418c950ee Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Mon, 7 Aug 2023 15:22:09 +0200 Subject: [PATCH 2/2] Add test case for multiple ids --- js/tests/unit/dom/selector-engine.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/tests/unit/dom/selector-engine.spec.js b/js/tests/unit/dom/selector-engine.spec.js index 8dd7b1f893fd..72c0bf6db86f 100644 --- a/js/tests/unit/dom/selector-engine.spec.js +++ b/js/tests/unit/dom/selector-engine.spec.js @@ -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 = [ + '
', + '
', + '
' + ].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 = [ '',