diff --git a/js/dropdown.js b/js/dropdown.js index c4e5f65dfc77..4ded85012118 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -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() } diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 566b50ee7e12..747bf60d9e51 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -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 = [ + '