Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

[Fixes #249] Use parse5 for standard-compliant parsing #251

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 32 additions & 5 deletions dist/browser/bootlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10379,6 +10379,31 @@ if (typeof define === 'function' && define.amd)
);

},{}],4:[function(require,module,exports){
/**
* This file automatically generated from `pre-publish.js`.
* Do not manually edit.
*/

module.exports = {
"area": true,
"base": true,
"br": true,
"col": true,
"embed": true,
"hr": true,
"img": true,
"input": true,
"keygen": true,
"link": true,
"menuitem": true,
"meta": true,
"param": true,
"source": true,
"track": true,
"wbr": true
};

},{}],5:[function(require,module,exports){
/*!
* Bootlint - an HTML linter for Bootstrap projects
* https://github.com/twbs/bootlint
Expand All @@ -10388,9 +10413,10 @@ if (typeof define === 'function' && define.amd)

/*eslint-env node */

var cheerio = require('cheerio');
var cheerio = require('whacko');
var parseUrl = require('url').parse;
var semver = require('semver');
var voidElements = require('void-elements');
var _location = require('./location');
var LocationIndex = _location.LocationIndex;

Expand Down Expand Up @@ -11209,15 +11235,16 @@ var LocationIndex = _location.LocationIndex;
});
addLinter("W009", function lintEmptySpacerCols($, reporter) {
var selector = COL_CLASSES.map(function (colClass) {
return colClass + ':not(col):not(:last-child)';
return colClass + ':not(:last-child)';
}).join(',');
var columns = $(selector);
columns.each(function (_index, col) {
var column = $(col);
var isVoidElement = voidElements[col.tagName.toLowerCase()];
// can't just use :empty because :empty excludes nodes with all-whitespace text content
var hasText = !!column.text().trim().length;
var hasChildren = !!column.children(':first-child').length;
if (hasChildren || hasText) {
if (hasChildren || hasText || isVoidElement) {
return;
}

Expand Down Expand Up @@ -11458,7 +11485,7 @@ var LocationIndex = _location.LocationIndex;
}
})(typeof exports === 'object' && exports || this);

},{"./location":1,"cheerio":2,"semver":3,"url":5}],5:[function(require,module,exports){
},{"./location":1,"semver":3,"url":6,"void-elements":4,"whacko":2}],6:[function(require,module,exports){
/*eslint-env node, browser */
/* jshint browser: true */
/**
Expand Down Expand Up @@ -11498,4 +11525,4 @@ var LocationIndex = _location.LocationIndex;
exports.parse = parse;
})();

},{}]},{},[4]);
},{}]},{},[5]);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"bluebird": "^2.9.12",
"body-parser": "^1.12.0",
"chalk": "^1.0.0",
"cheerio": "^0.18.0",
"whacko": "^0.17.4",
"commander": "^2.6.0",
"debug": "^2.1.1",
"express": "^4.11.2",
Expand All @@ -73,7 +73,7 @@
},
"browser": {
"binary-search": false,
"cheerio": "jquery",
"whacko": "jquery",
"url": "./src/url.js",
"./cli": false,
"./location": false
Expand Down
18 changes: 9 additions & 9 deletions src/bootlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/*eslint-env node */

var cheerio = require('cheerio');
var whacko = require('whacko');
var parseUrl = require('url').parse;
var semver = require('semver');
var voidElements = require('void-elements');
Expand All @@ -33,7 +33,7 @@ var LocationIndex = _location.LocationIndex;
'lg': 3
};
var NUM2SCREEN = ['xs', 'sm', 'md', 'lg'];
var IN_NODE_JS = !!(cheerio.load);
var IN_NODE_JS = !!(whacko.load);
var MIN_JQUERY_VERSION = '1.9.1';// as of Bootstrap v3.3.0
var CURRENT_BOOTSTRAP_VERSION = '3.3.2';

Expand Down Expand Up @@ -183,26 +183,26 @@ var LocationIndex = _location.LocationIndex;
/**
* @param {integer} id Unique string ID for this type of lint error. Of the form "E###" (e.g. "E123").
* @param {string} message Human-readable string describing the error
* @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
* @param {jQuery} elements jQuery or Whacko collection of referenced DOM elements pointing to all problem locations in the document
* @class
*/
function LintError(id, message, elements) {
this.id = id;
this.message = message;
this.elements = elements || cheerio('');
this.elements = elements || whacko('');
}
exports.LintError = LintError;

/**
* @param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123").
* @param {string} message Human-readable string describing the warning
* @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
* @param {jQuery} elements jQuery or Whacko collection of referenced DOM elements pointing to all problem locations in the document
* @class
*/
function LintWarning(id, message, elements) {
this.id = id;
this.message = message;
this.elements = elements || cheerio('');
this.elements = elements || whacko('');
}
exports.LintWarning = LintWarning;

Expand Down Expand Up @@ -998,7 +998,7 @@ var LocationIndex = _location.LocationIndex;
*/

if (IN_NODE_JS) {
// cheerio; Node.js
// whacko; Node.js
/**
* Lints the given HTML.
* @param {string} html The HTML to lint
Expand All @@ -1007,15 +1007,15 @@ var LocationIndex = _location.LocationIndex;
* @returns {undefined} Nothing
*/
exports.lintHtml = function (html, reporter, disabledIds) {
var $ = cheerio.load(html, {withStartIndices: true});
var $ = whacko.load(html, {withStartIndices: true});
this._lint($, reporter, disabledIds, html);
};
}
else {
// jQuery; in-browser
/* @covignore */
(function () {
var $ = cheerio;
var $ = whacko;
/**
* Lints the HTML of the current document.
* @param {reporter} reporter Function to call with each lint problem
Expand Down
Loading