Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jQuery version check to existing jQuery presence check #14852

Merged
merged 1 commit into from
Oct 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,21 @@ module.exports = function (grunt) {
' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
' */\n',
// NOTE: This jqueryCheck code is duplicated in customizer.js; if making changes here, be sure to update the other copy too.
jqueryCheck: 'if (typeof jQuery === \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n',
// NOTE: This jqueryCheck/jqueryVersionCheck code is duplicated in customizer.js;
// if making changes here, be sure to update the other copy too.
jqueryCheck: [
'if (typeof jQuery === \'undefined\') {',
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\')',
'}\n'
].join('\n'),
jqueryVersionCheck: [
'+function ($) {',
' var version = $.fn.jquery.split(\' \')[0].split(\'.\')',
' if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {',
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery version 1.9.1 or higher\')',
' }',
'}(jQuery);\n\n'
].join('\n'),

// Task configuration.
clean: {
Expand Down Expand Up @@ -93,7 +106,7 @@ module.exports = function (grunt) {

concat: {
options: {
banner: '<%= banner %>\n<%= jqueryCheck %>',
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
stripBanners: false
},
bootstrap: {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"test-infra"
],
"dependencies": {
"jquery": ">= 1.9.0"
"jquery": ">= 1.9.1"
}
}
16 changes: 14 additions & 2 deletions docs/assets/js/src/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,19 @@ window.onload = function () { // wait for load in a dumb way because B-0

function generateJS(preamble) {
var $checked = $('#plugin-section input:checked')
var jqueryCheck = 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap\'s JavaScript requires jQuery") }\n\n'
var jqueryCheck = [
'if (typeof jQuery === \'undefined\') {',
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\')',
'}\n'
].join('\n')
var jqueryVersionCheck = [
'+function ($) {',
' var version = $.fn.jquery.split(\' \')[0].split(\'.\')',
' if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {',
' throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery version 1.9.1 or higher\')',
' }',
'}(jQuery);\n\n'
].join('\n')

if (!$checked.length) return false

Expand All @@ -329,7 +341,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
.join('\n')

preamble = cw + preamble
js = jqueryCheck + js
js = jqueryCheck + jqueryVersionCheck + js

return {
'bootstrap.js': preamble + js,
Expand Down