mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-08 17:22:31 +03:00
#11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object
This commit is contained in:
+20
-11
@@ -1,19 +1,28 @@
|
||||
$(function () {
|
||||
|
||||
module('alert')
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
var alert = $.fn.alert.noConflict()
|
||||
ok(!$.fn.alert, 'alert was set back to undefined (org value)')
|
||||
$.fn.alert = alert
|
||||
})
|
||||
module('alert plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
ok($(document.body).alert, 'alert method is defined')
|
||||
})
|
||||
|
||||
module('alert', {
|
||||
setup: function() {
|
||||
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
|
||||
$.fn.bootstrapAlert = $.fn.alert.noConflict()
|
||||
},
|
||||
teardown: function() {
|
||||
$.fn.alert = $.fn.bootstrapAlert
|
||||
delete $.fn.bootstrapAlert
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
ok(!$.fn.alert, 'alert was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return element', function () {
|
||||
ok($(document.body).alert()[0] == document.body, 'document.body returned')
|
||||
ok($(document.body).bootstrapAlert()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test('should fade element out on clicking .close', function () {
|
||||
@@ -21,7 +30,7 @@ $(function () {
|
||||
'<a class="close" href="#" data-dismiss="alert">×</a>' +
|
||||
'<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
|
||||
'</div>',
|
||||
alert = $(alertHTML).alert()
|
||||
alert = $(alertHTML).bootstrapAlert()
|
||||
|
||||
alert.find('.close').click()
|
||||
|
||||
@@ -35,7 +44,7 @@ $(function () {
|
||||
'<a class="close" href="#" data-dismiss="alert">×</a>' +
|
||||
'<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
|
||||
'</div>',
|
||||
alert = $(alertHTML).appendTo('#qunit-fixture').alert()
|
||||
alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert()
|
||||
|
||||
ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
|
||||
|
||||
@@ -56,7 +65,7 @@ $(function () {
|
||||
.on('closed.bs.alert', function () {
|
||||
ok(false)
|
||||
})
|
||||
.alert('close')
|
||||
.bootstrapAlert('close')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user