diff --git a/lib/api/attributes.js b/lib/api/attributes.js index c3a87c6862..f89be4a1c6 100644 --- a/lib/api/attributes.js +++ b/lib/api/attributes.js @@ -238,7 +238,7 @@ exports.removeAttr = function(name) { }; exports.hasClass = function(className) { - return _.any(this, function(elem) { + return _.some(this, function(elem) { var attrs = elem.attribs, clazz = attrs && attrs['class'], idx = -1, diff --git a/lib/api/manipulation.js b/lib/api/manipulation.js index 7e7670a16a..2cd4d80ab2 100644 --- a/lib/api/manipulation.js +++ b/lib/api/manipulation.js @@ -114,7 +114,7 @@ exports.wrap = function(wrapper) { var wrapperFn = typeof wrapper === 'function' && wrapper, lastIdx = this.length - 1; - _.forEach(this, function(el, i) { + _.forEach(this, _.bind(function(el, i) { var parent = el.parent || el.root, siblings = parent.children, dom, index; @@ -139,7 +139,7 @@ exports.wrap = function(wrapper) { // array, so the `dom` array can be inserted without removing any // additional elements. uniqueSplice(siblings, index, 0, dom, parent); - }, this); + }, this)); return this; }; diff --git a/lib/api/traversing.js b/lib/api/traversing.js index bda433ea66..b08d587dea 100644 --- a/lib/api/traversing.js +++ b/lib/api/traversing.js @@ -261,8 +261,7 @@ exports.siblings = function(selector) { var elems = _.filter( parent ? parent.children() : this.siblingsAndMe(), - function(elem) { return isTag(elem) && !this.is(elem); }, - this + _.bind(function(elem) { return isTag(elem) && !this.is(elem); }, this) ); if (selector !== undefined) { diff --git a/lib/cheerio.js b/lib/cheerio.js index f0ecd3e476..5b1156ab55 100644 --- a/lib/cheerio.js +++ b/lib/cheerio.js @@ -44,9 +44,9 @@ var Cheerio = module.exports = function(selector, context, root, options) { // $([dom]) if (Array.isArray(selector)) { - _.forEach(selector, function(elem, idx) { + _.forEach(selector, _.bind(function(elem, idx) { this[idx] = elem; - }, this); + }, this)); this.length = selector.length; return this; } diff --git a/package.json b/package.json index 19517cd5df..35725b0e39 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "entities": "~1.1.1", "htmlparser2": "~3.8.1", "dom-serializer": "~0.1.0", - "lodash": "^3.2.0" + "lodash": "^4.1.0" }, "devDependencies": { "benchmark": "~1.0.0",