From f8fc167e986b5bd94f31cb6501a1e031a80b4677 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Mon, 18 Sep 2023 01:30:29 +0300 Subject: [PATCH] fix: regression of #38989 --- js/src/dom/selector-engine.js | 6 +++--- js/tests/unit/modal.spec.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index a47f72001bd5..013971c255ed 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 !== '#' ? parseSelector(hrefAttribute.trim()) : null + selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null } - - return selector + + return selector.split(',').map(sel=>parseSelector(sel)).join(',') } const SelectorEngine = { diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 6434d8b3cca2..d3be6f776e16 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -989,6 +989,36 @@ describe('Modal', () => { trigger.click() }) }) + + it('should open modal, having special characters in its id', () => { + return new Promise(resolve => { + fixtureEl.innerHTML = [ + '', + '', + ].join('') + + const modalEl = fixtureEl.querySelector('.modal') + const trigger = fixtureEl.querySelector('[data-bs-toggle="modal"]') + + + modalEl.addEventListener('shown.bs.modal', () => { + resolve() + }) + + trigger.click() + }) + }) + it('should not prevent default when a click occurred on data-bs-dismiss="modal" where tagName is DIFFERENT than or ', () => { return new Promise(resolve => { fixtureEl.innerHTML = [