aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-09-27 10:39:11 +0300
committerGitHub <[email protected]>2022-09-27 10:39:11 +0300
commit597c4023141dc48868889b85676b2d7269411d23 (patch)
treee4ab90fa59bd98daaaa69942c3564706b962268b /js/tests/unit
parente77367dddc1a523b6a7197735dbef7cd63d62fe9 (diff)
downloadbootstrap-597c4023141dc48868889b85676b2d7269411d23.tar.xz
bootstrap-597c4023141dc48868889b85676b2d7269411d23.zip
Dropdown: fix case with invalid markup (#37190)
This fixes a backward incompatible change in v5.2.1 where `.drodown-toggle` isn't present in the markup.
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/dropdown.spec.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js
index ea7ddace3..2bbd7c00a 100644
--- a/js/tests/unit/dropdown.spec.js
+++ b/js/tests/unit/dropdown.spec.js
@@ -57,6 +57,28 @@ 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('')
+
+ const dropdownElem = fixtureEl.querySelector('.dropdown-menu')
+ const dropdown = new Dropdown(dropdownElem)
+
+ dropdownElem.addEventListener('shown.bs.dropdown', () => {
+ resolve()
+ })
+
+ dropdown.show()
+ })
+ })
+
it('should create offset modifier correctly when offset option is a function', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [