提交 2b75704e 编写于 作者: F Felix Böhm

Upgrade dependencies

上级 1dcf8636
......@@ -26,12 +26,12 @@ Please make sure commit hooks are run, which will enforce the code style.
When implementing private functionality that isn't part of the jQuery API, please opt for:
* _Static methods_: If the functionality does not require a reference to a
- _Static methods_: If the functionality does not require a reference to a
Cheerio instance, simply define a named function within the module it is
needed.
* _Instance methods_: If the functionality requires a reference to a Cheerio
- _Instance methods_: If the functionality requires a reference to a Cheerio
instance, informally define the method as "private" using the following
conventions:
* Define the method as a function on the Cheerio prototype
* Prefix the method name with an underscore (`_`) character
* Include `@api private` in the code comment the documents the method
- Define the method as a function on the Cheerio prototype
- Prefix the method name with an underscore (`_`) character
- Include `@api private` in the code comment the documents the method
此差异已折叠。
......@@ -171,8 +171,8 @@ object to `.load()`:
```js
const $ = cheerio.load('<ul id="fruits">...</ul>', {
xml: {
normalizeWhitespace: true
}
normalizeWhitespace: true,
},
});
```
......@@ -293,7 +293,7 @@ Once you have loaded a document, you may extend the prototype or the equivalent
```js
const $ = cheerio.load('<html><body>Hello, <b>world</b>!</body></html>');
$.prototype.logHtml = function() {
$.prototype.logHtml = function () {
console.log(this.html());
};
......
theme: jekyll-theme-cayman
\ No newline at end of file
theme: jekyll-theme-cayman
......@@ -16,101 +16,101 @@ if (process.argv.indexOf('--cheerio-only') >= 0) {
}
suites.add('Select all', 'jquery.html', {
test: function($) {
test: function ($) {
$('*').length;
}
},
});
suites.add('Select some', 'jquery.html', {
test: function($) {
test: function ($) {
$('li').length;
}
},
});
/*
* Manipulation Tests
*/
suites.add('manipulation - append', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $body) {
test: function ($, $body) {
$body.append(new Array(50).join('<div>'));
}
},
});
// These tests run out of memory in jsdom
suites.add('manipulation - prepend - highmem', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $body) {
test: function ($, $body) {
$body.prepend(new Array(50).join('<div>'));
}
},
});
suites.add('manipulation - after - highmem', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $body) {
test: function ($, $body) {
$body.after(new Array(50).join('<div>'));
}
},
});
suites.add('manipulation - before - highmem', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $body) {
test: function ($, $body) {
$body.before(new Array(50).join('<div>'));
}
},
});
suites.add('manipulation - remove', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $lis) {
test: function ($, $lis) {
var child = $('<div>');
$lis.append(child);
child.remove();
}
},
});
suites.add('manipulation - replaceWith', 'jquery.html', {
setup: function($) {
setup: function ($) {
$('body').append('<div id="foo">');
},
test: function($) {
test: function ($) {
$('#foo').replaceWith('<div id="foo">');
}
},
});
suites.add('manipulation - empty', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.empty();
}
},
});
suites.add('manipulation - html', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.html();
$lis.html('foo');
}
},
});
suites.add('manipulation - html render', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.html();
}
},
});
suites.add('manipulation - html independent', 'jquery.html', {
setup: function() {
setup: function () {
return (
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
......@@ -120,218 +120,218 @@ suites.add('manipulation - html independent', 'jquery.html', {
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
);
},
test: function($, content) {
test: function ($, content) {
$(content).html();
}
},
});
suites.add('manipulation - text', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.text();
$lis.text('foo');
}
},
});
/*
* Traversing Tests
*/
suites.add('traversing - Find', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.find('li').length;
}
},
});
suites.add('traversing - Parent', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.parent('div').length;
}
},
});
suites.add('traversing - Parents', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.parents('div').length;
}
},
});
suites.add('traversing - Closest', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.closest('div').length;
}
},
});
suites.add('traversing - next', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.next().length;
}
},
});
suites.add('traversing - nextAll', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.nextAll('li').length;
}
},
});
suites.add('traversing - nextUntil', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.nextUntil('li').length;
}
},
});
suites.add('traversing - prev', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.prev().length;
}
},
});
suites.add('traversing - prevAll', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.prevAll('li').length;
}
},
});
suites.add('traversing - prevUntil', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.prevUntil('li').length;
}
},
});
suites.add('traversing - siblings', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.siblings('li').length;
}
},
});
suites.add('traversing - Children', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.children('a').length;
}
},
});
suites.add('traversing - Filter', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.filter('li').length;
}
},
});
suites.add('traversing - First', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.first().first().length;
}
},
});
suites.add('traversing - Last', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.last().last().length;
}
},
});
suites.add('traversing - Eq', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.eq(0).eq(0).length;
}
},
});
/*
* Attributes Tests
*/
suites.add('attributes - Attributes', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.attr('foo', 'bar');
$lis.attr('foo');
$lis.removeAttr('foo');
}
},
});
suites.add('attributes - Single Attribute', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('body');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.attr('foo', 'bar');
$lis.attr('foo');
$lis.removeAttr('foo');
}
},
});
suites.add('attributes - Data', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.data('foo', 'bar');
$lis.data('foo');
}
},
});
suites.add('attributes - Val', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('select,input,textarea,option');
},
test: function($, $lis) {
$lis.each(function() {
test: function ($, $lis) {
$lis.each(function () {
$(this).val();
$(this).val('foo');
});
}
},
});
suites.add('attributes - Has class', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.hasClass('foo');
}
},
});
suites.add('attributes - Toggle class', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.toggleClass('foo');
}
},
});
suites.add('attributes - Add Remove class', 'jquery.html', {
setup: function($) {
setup: function ($) {
return $('li');
},
test: function($, $lis) {
test: function ($, $lis) {
$lis.addClass('foo');
$lis.removeClass('foo');
}
},
});
此差异已折叠。
......@@ -14,17 +14,17 @@ var jQueryScript = new Script(jQuerySrc);
var filterRe = /./;
var cheerioOnly = false;
var Suites = (module.exports = function() {});
var Suites = (module.exports = function () {});
Suites.prototype.filter = function(str) {
Suites.prototype.filter = function (str) {
filterRe = new RegExp(str, 'i');
};
Suites.prototype.cheerioOnly = function() {
Suites.prototype.cheerioOnly = function () {
cheerioOnly = true;
};
Suites.prototype.add = function(name, fileName, options) {
Suites.prototype.add = function (name, fileName, options) {
var markup, suite;
if (!filterRe.test(name)) {
return;
......@@ -32,21 +32,21 @@ Suites.prototype.add = function(name, fileName, options) {
markup = fs.readFileSync(path.join(documentDir, fileName), 'utf8');
suite = new Benchmark.Suite(name);
suite.on('start', function() {
suite.on('start', function () {
console.log('Test: ' + name + ' (file: ' + fileName + ')');
});
suite.on('cycle', function(event) {
suite.on('cycle', function (event) {
if (event.target.error) {
return;
}
console.log('\t' + String(event.target));
});
suite.on('error', function(event) {
suite.on('error', function (event) {
console.log('*** Error in ' + event.target.name + ': ***');
console.log('\t' + event.target.error);
console.log('*** Test invalidated. ***');
});
suite.on('complete', function(event) {
suite.on('complete', function (event) {
if (event.target.error) {
console.log();
return;
......@@ -62,7 +62,7 @@ Suites.prototype.add = function(name, fileName, options) {
}
};
Suites.prototype._benchJsDom = function(suite, markup, options) {
Suites.prototype._benchJsDom = function (suite, markup, options) {
var testFn = options.test;
var dom = new JSDOM(markup, { runScripts: 'outside-only' });
......@@ -73,20 +73,20 @@ Suites.prototype._benchJsDom = function(suite, markup, options) {
if (options.setup) {
setupData = options.setup.call(null, dom.window.$);
}
suite.add('jsdom', function() {
suite.add('jsdom', function () {
testFn.call(null, dom.window.$, setupData);
});
suite.run();
};
Suites.prototype._benchCheerio = function(suite, markup, options) {
Suites.prototype._benchCheerio = function (suite, markup, options) {
var $ = cheerio.load(markup);
var testFn = options.test;
var setupData;
if (options.setup) {
setupData = options.setup.call(null, $);
}
suite.add('cheerio', function() {
suite.add('cheerio', function () {
testFn.call(null, $, setupData);
});
};
......@@ -23,25 +23,27 @@ exports.xml = staticMethods.xml;
/**
* In order to promote consistency with the jQuery library, users are
* encouraged to instead use the static method of the same name. For example:
* encouraged to instead use the static method of the same name.
*
* @example
* var $ = cheerio.load('<div><p></p></div>');
* $.contains($('div').get(0), $('p').get(0)); // true
* $.contains($('p').get(0), $('div').get(0)); // false
*
* @method
* @function
* @deprecated
*/
exports.contains = staticMethods.contains;
/**
* In order to promote consistency with the jQuery library, users are
* encouraged to instead use the static method of the same name. For example:
* encouraged to instead use the static method of the same name.
*
* @example
* var $ = cheerio.load('');
* $.merge([1, 2], [3, 4]) // [1, 2, 3, 4]
*
* @method
* @function
* @deprecated
*/
exports.merge = staticMethods.merge;
......@@ -49,25 +51,26 @@ exports.merge = staticMethods.merge;
/**
* In order to promote consistency with the jQuery library, users are
* encouraged to instead use the static method of the same name as it is
* defined on the "loaded" Cheerio factory function. For example:
* defined on the "loaded" Cheerio factory function.
*
* @example
* var $ = cheerio.load('');
* $.parseHTML('<b>markup</b>');
*
* @method
* @deprecated see {@link static/parseHTML}
* @function
* @deprecated See {@link static/parseHTML}.
*/
exports.parseHTML = staticMethods.parseHTML;
/**
* Users seeking to access the top-level element of a parsed document should
* instead use the `root` static method of a "loaded" Cheerio function. For
* example:
* instead use the `root` static method of a "loaded" Cheerio function.
*
* @example
* var $ = cheerio.load('');
* $.root();
*
* @method
* @function
* @deprecated
*/
exports.root = staticMethods.root;
......@@ -19,21 +19,21 @@ var text = require('../static').text,
_ = {
forEach: require('lodash/forEach'),
extend: require('lodash/assignIn'),
some: require('lodash/some')
some: require('lodash/some'),
},
// Lookup table for coercing string data-* attributes to their corresponding
// JavaScript primitives