mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-18 10:52:19 +01:00
handle # selector for dropdown
This commit is contained in:
parent
a43077d3c3
commit
2ccfa57467
@ -29,7 +29,7 @@
|
||||
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
||||
}
|
||||
|
||||
var $parent = selector && $(document).find(selector)
|
||||
var $parent = selector !== '#' ? $(document).find(selector) : null
|
||||
|
||||
return $parent && $parent.length ? $parent : $this.parent()
|
||||
}
|
||||
|
@ -420,4 +420,35 @@ $(function () {
|
||||
|
||||
assert.ok($dropdown.parent('.btn-group').hasClass('open'), 'dropdown menu is open')
|
||||
})
|
||||
|
||||
QUnit.test('should handle # in data-target', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
|
||||
var html = [
|
||||
'<div class="dropdown">',
|
||||
' <a id="dLabel" data-target="#" href="http://example.com/" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">',
|
||||
' Dropdown trigger',
|
||||
' </a>',
|
||||
' <ul class="dropdown-menu" aria-labelledby="dLabel">',
|
||||
' <li><a href="/test">One</a></li>',
|
||||
' <li><a href="/test2">Two</a></li>',
|
||||
' </ul>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
var $dropdown = $(html)
|
||||
.appendTo('#qunit-fixture')
|
||||
.find('[data-toggle="dropdown"]')
|
||||
.bootstrapDropdown()
|
||||
|
||||
$dropdown
|
||||
.parent('.dropdown')
|
||||
.on('shown.bs.dropdown', function () {
|
||||
assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
|
||||
done()
|
||||
})
|
||||
|
||||
$dropdown.trigger('click')
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user