'
@@ -487,27 +487,11 @@ $(function () {
.on('shown.bs.dropdown', function () {
assert.ok(true, 'shown was fired')
- // Space key
- $input.trigger('focus').trigger($.Event('keydown', { which: 32 }))
- assert.ok($(document.activeElement)[0] === $input[0], 'input still focused')
- $textarea.trigger('focus').trigger($.Event('keydown', { which: 32 }))
- assert.ok($(document.activeElement)[0] === $textarea[0], 'textarea still focused')
-
- // Key up
$input.trigger('focus').trigger($.Event('keydown', { which: 38 }))
- assert.ok($(document.activeElement)[0] === $input[0], 'input still focused')
+ assert.ok($(document.activeElement).is($input), 'input still focused')
+
$textarea.trigger('focus').trigger($.Event('keydown', { which: 38 }))
- assert.ok($(document.activeElement)[0] === $textarea[0], 'textarea still focused')
-
- // Key down
- $input.trigger('focus').trigger($.Event('keydown', { which: 40 }))
- assert.ok($(document.activeElement)[0] === $input[0], 'input still focused')
- $textarea.trigger('focus').trigger($.Event('keydown', { which: 40 }))
- assert.ok($(document.activeElement)[0] === $textarea[0], 'textarea still focused')
-
- // Key escape
- $input.trigger('focus').trigger($.Event('keydown', { which: 27 }))
- assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is not shown')
+ assert.ok($(document.activeElement).is($textarea), 'textarea still focused')
done()
})
@@ -515,126 +499,6 @@ $(function () {
$dropdown.trigger('click')
})
- QUnit.test('should ignore space key events for
s within dropdown, and accept up, down and escape', function (assert) {
- assert.expect(6)
- var done = assert.async()
-
- var dropdownHTML = '
'
- var $dropdown = $(dropdownHTML)
- .appendTo('#qunit-fixture')
- .find('[data-toggle="dropdown"]')
- .bootstrapDropdown()
-
- var $input = $('#input')
-
- $dropdown
- .parent('.dropdown')
- .one('shown.bs.dropdown', function () {
- assert.ok(true, 'shown was fired')
-
- // Key space
- $input.trigger('focus').trigger($.Event('keydown', { which: 32 }))
- assert.ok($dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is shown')
- assert.ok($(document.activeElement).is($input), 'input is still focused')
-
- // Key escape
- $input.trigger('focus').trigger($.Event('keydown', { which: 27 }))
- assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is not shown')
-
- $dropdown
- .parent('.dropdown')
- .one('shown.bs.dropdown', function () {
-
- // Key down
- $input.trigger('focus').trigger($.Event('keydown', { which: 40 }))
- assert.ok(document.activeElement === $('#item1')[0], 'item1 is focused')
-
- $dropdown
- .parent('.dropdown')
- .one('shown.bs.dropdown', function () {
-
- // Key up
- $input.trigger('focus').trigger($.Event('keydown', { which: 38 }))
- assert.ok(document.activeElement === $('#item1')[0], 'item1 is focused')
- done()
- }).bootstrapDropdown('toggle')
- $input.trigger('click')
- })
- $input.trigger('click')
- })
- $input.trigger('click')
- })
-
- QUnit.test('should ignore space key events for