Conversation
6f52f39 to
19016a6
Compare
19016a6 to
9416ace
Compare
There was a problem hiding this comment.
I haven't checked everything in detail but I was thinking about the same kind of patch when I tried to analyse the issue.
Your patch fixes the issue, and the multiple target ids system is still working.
Ideas of improvement:
- Add a new test with a multiple target ids containing special chars; something like the following:
it('should get elements if several ids with special chars are given', () => {
fixtureEl.innerHTML = [
'<div id="test" data-bs-target="#j_id11:exampleModal,#j_id22:exampleModal"></div>',
'<div class="target" id="j_id11:exampleModal"></div>',
'<div class="target" id="j_id22:exampleModal"></div>'
].join('')
const testEl = fixtureEl.querySelector('#test')
expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
})- Add other tests with weird authorized characters as IDs to check that the selector engine escapes the special chars when needed. If I understand well the HTML 5 spec, it seems that almost all characters are authorized except spaces in IDs.
- Note: not for this PR but maybe in the future we should change the separator for
data-bs-target(with multiple targets) to replace,which seems to be authorized as a character in IDs.
- Note: not for this PR but maybe in the future we should change the separator for
FWIW, it doesn't seem that #39198 is linked to this regression and is rather linked to some bad usage + a possible missing escape of characters in scrollspy's JS with anchors. So another topic.
julien-deramond
left a comment
There was a problem hiding this comment.
LGTM as explained in #39201 (review).
I've added an unit test for SelectorEngine too via e9c649b. Feel free to revert this commit if you don't agree with this approach.
@XhmikosR and/or @GeoSot, I let you double-check this fix in depth and determine if we need to release it in v5.3.3 soon.
Description
Motivation & Context
A draft solution, which supports multiple ids, and usage off CSS.escape at the same time
Type of changes
Checklist
npm run lint)Live previews
Related issues
Ref: #38989 , #339198
closes: #39189