diff --git a/dist/browser/bootlint.js b/dist/browser/bootlint.js index a878dbf..49c4929 100644 --- a/dist/browser/bootlint.js +++ b/dist/browser/bootlint.js @@ -1,4 +1,4 @@ -/*! bootlint - v0.1.1 - 2014-07-31 */ +/*! bootlint - v0.1.1 - 2014-08-20 */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;olabel>input[type="checkbox"])').length <= 0; @@ -9485,6 +9506,7 @@ var cheerio = require('cheerio'); errs.push(this.lintFormGroupMixedWithInputGroup($)); errs.push(this.lintGridClassMixedWithInputGroup($)); errs.push(this.lintInputGroupsWithMultipleAddOnsPerSide($)); + errs.push(this.lintBtnToggle($)); errs.push(this.lintBlockCheckboxes($)); errs.push(this.lintBlockRadios($)); errs.push(this.lintButtonsCheckedActive($)); @@ -9492,7 +9514,9 @@ var cheerio = require('cheerio'); errs = errs.concat(this.lintInputGroupFormControlTypes($)); errs = errs.concat(this.lintInlineCheckboxes($)); errs = errs.concat(this.lintInlineRadios($)); - errs = errs.filter(function (item) { return item !== undefined; }); + errs = errs.filter(function (item) { + return item !== undefined; + }); return errs; }; if (IN_NODE_JS) { @@ -9527,18 +9551,22 @@ var cheerio = require('cheerio'); exports.showLintReportForCurrentDocument = function () { var errs = this.lintCurrentDocument(); if (errs.length) { + /*eslint-disable no-alert, no-undef */ window.alert("bootlint found errors in this document! See the JavaScript console for details."); + /*eslint-enable no-alert, no-undef */ errs.forEach(function (err) { console.warn("bootlint:", err); }); } }; + /*eslint-disable no-undef */ window.bootlint = exports; + /*eslint-enable no-undef */ $(function () { exports.showLintReportForCurrentDocument(); }); })(); } -}(typeof exports === 'object' && exports || this)); +})(typeof exports === 'object' && exports || this); },{"cheerio":1}]},{},[2]); \ No newline at end of file diff --git a/src/bootlint.js b/src/bootlint.js index 5feecef..b2a7f17 100644 --- a/src/bootlint.js +++ b/src/bootlint.js @@ -223,6 +223,12 @@ var cheerio = require('cheerio'); return "Having multiple add-ons on a single side of an input group is not supported"; } }; + exports.lintBtnToggle = function ($) { + var badBtnToggle = $('.btn.dropdown-toggle ~ .btn'); + if (badBtnToggle.length) { + return "`.btn.dropdown-toggle` must be the last button in a button group."; + } + }; exports.lintBlockCheckboxes = function ($) { var badCheckboxes = $('.checkbox').filter(function (i, div) { return $(div).filter(':has(>label>input[type="checkbox"])').length <= 0; @@ -305,6 +311,7 @@ var cheerio = require('cheerio'); errs.push(this.lintFormGroupMixedWithInputGroup($)); errs.push(this.lintGridClassMixedWithInputGroup($)); errs.push(this.lintInputGroupsWithMultipleAddOnsPerSide($)); + errs.push(this.lintBtnToggle($)); errs.push(this.lintBlockCheckboxes($)); errs.push(this.lintBlockRadios($)); errs.push(this.lintButtonsCheckedActive($)); diff --git a/test/bootlint_test.js b/test/bootlint_test.js index 3e88414..8f3a043 100644 --- a/test/bootlint_test.js +++ b/test/bootlint_test.js @@ -232,6 +232,16 @@ exports['bootlint'] = { 'should complain when both a normal add-on and a button add-on are on the left side of an input group.'); test.done(); }, + 'dropdown-toggle comes before btn': function (test) { + test.expect(2); + test.deepEqual(bootlint.lintHtml(utf8Fixture('buttons/btn-toggle.html')), + [], + 'should not complain when correct .dropdown-toggle markup is used.'); + test.deepEqual(bootlint.lintHtml(utf8Fixture('buttons/btn-toggle-after-btn.html')), + ["`.btn.dropdown-toggle` must be the last button in a button group."], + 'should complain when `.dropdown-toggle` is on the left side of a btn'); + test.done(); + }, 'incorrect markup for .checkbox, .radio, .checkbox-inline, and .radio-inline classes': function (test) { test.expect(7); diff --git a/test/fixtures/buttons/.btn-toggle-after-btn.html.swp b/test/fixtures/buttons/.btn-toggle-after-btn.html.swp new file mode 100644 index 0000000..2db2a8b Binary files /dev/null and b/test/fixtures/buttons/.btn-toggle-after-btn.html.swp differ diff --git a/test/fixtures/buttons/.btn-toggle.html.swp b/test/fixtures/buttons/.btn-toggle.html.swp new file mode 100644 index 0000000..43e5c8b Binary files /dev/null and b/test/fixtures/buttons/.btn-toggle.html.swp differ diff --git a/test/fixtures/buttons/btn-toggle-after-btn.html b/test/fixtures/buttons/btn-toggle-after-btn.html new file mode 100644 index 0000000..bf805a8 --- /dev/null +++ b/test/fixtures/buttons/btn-toggle-after-btn.html @@ -0,0 +1,41 @@ + + + + + + + Test + + + + + + + + + + +
+ + + +
+ +
+
    +
  1. +
+ + diff --git a/test/fixtures/buttons/btn-toggle.html b/test/fixtures/buttons/btn-toggle.html new file mode 100644 index 0000000..82145fd --- /dev/null +++ b/test/fixtures/buttons/btn-toggle.html @@ -0,0 +1,71 @@ + + + + + + + Test + + + + + + + + + + + +
+ + + +
+ + +
+ + + +
+ + +
+
+ + +
+ + +
+ +
+
    + +