Permalink
Browse files

Merge pull request #533 from jugglinmike/unused

Remove unused variable references
  • Loading branch information...
davidchambers committed Jul 1, 2014
2 parents f14d818 + d8c5905 commit ce39046918bf6a88202f9100aacf979299423dc0
Showing with 102 additions and 92 deletions.
  1. +1 −0 .jshintrc
  2. +18 −12 lib/api/attributes.js
  3. +12 −13 lib/api/manipulation.js
  4. +43 −36 lib/api/traversing.js
  5. +1 −2 lib/cheerio.js
  6. +5 −6 lib/parse.js
  7. +8 −8 lib/static.js
  8. +4 −4 test/api.attributes.js
  9. +4 −4 test/api.manipulation.js
  10. +5 −5 test/api.traversing.js
  11. +1 −1 test/cheerio.js
  12. +0 −1 test/xml.js
View
@@ -4,6 +4,7 @@
"laxbreak": true,
"proto": true,
"undef": true,
"unused": true,
"node": true,
"quotmark": "single",
"globals": {
View
@@ -49,7 +49,7 @@ var setAttr = function(el, name, value) {
}
};
var attr = exports.attr = function(name, value) {
exports.attr = function(name, value) {
// Set the value (with attr map support)
if (typeof name === 'object' || value !== undefined) {
if (typeof value === 'function') {
@@ -123,7 +123,7 @@ var readData = function(el, name) {
return readAll ? el.data : value;
};
var data = exports.data = function(name, value) {
exports.data = function(name, value) {
var elem = this[0];
if (!elem || !isTag(elem)) return;
@@ -154,7 +154,7 @@ var data = exports.data = function(name, value) {
* Get the value of an element
*/
var val = exports.val = function(value) {
exports.val = function(value) {
var querying = arguments.length === 0,
element = this[0];
@@ -237,15 +237,15 @@ var removeAttribute = function(elem, name) {
};
var removeAttr = exports.removeAttr = function(name) {
exports.removeAttr = function(name) {
domEach(this, function(i, elem) {
removeAttribute(elem, name);
});
return this;
};
var hasClass = exports.hasClass = function(className) {
exports.hasClass = function(className) {
return _.any(this, function(elem) {
var attrs = elem.attribs,
clazz = attrs && attrs['class'],
@@ -265,12 +265,12 @@ var hasClass = exports.hasClass = function(className) {
});
};
var addClass = exports.addClass = function(value) {
exports.addClass = function(value) {
// Support functions
if (typeof value === 'function') {
return domEach(this, function(i, el) {
var className = el.attribs['class'] || '';
addClass.call([el], value.call(el, i, className));
exports.addClass.call([el], value.call(el, i, className));
});
}
@@ -314,15 +314,17 @@ var splitClass = function(className) {
return className ? className.trim().split(rspace) : [];
};
var removeClass = exports.removeClass = function(value) {
exports.removeClass = function(value) {
var classes,
numClasses,
removeAll;
// Handle if value is a function
if (typeof value === 'function') {
return domEach(this, function(i, el) {
removeClass.call([el], value.call(el, i, el.attribs['class'] || ''));
exports.removeClass.call(
[el], value.call(el, i, el.attribs['class'] || '')
);
});
}
@@ -360,11 +362,15 @@ var removeClass = exports.removeClass = function(value) {
});
};
var toggleClass = exports.toggleClass = function(value, stateVal) {
exports.toggleClass = function(value, stateVal) {
// Support functions
if (typeof value === 'function') {
return domEach(this, function(i, el) {
toggleClass.call([el], value.call(el, i, el.attribs['class'] || '', stateVal), stateVal);
exports.toggleClass.call(
[el],
value.call(el, i, el.attribs['class'] || '', stateVal),
stateVal
);
});
}
@@ -404,7 +410,7 @@ var toggleClass = exports.toggleClass = function(value, stateVal) {
return this;
};
var is = exports.is = function (selector) {
exports.is = function (selector) {
if (selector) {
return this.filter(selector).length > 0;
}
View
@@ -5,7 +5,6 @@ var _ = require('lodash'),
evaluate = parse.evaluate,
utils = require('../utils'),
domEach = utils.domEach,
encode = utils.encode,
slice = Array.prototype.slice;
// Create an array of nodes, recursing into arrays and parsing strings if
@@ -99,15 +98,15 @@ var uniqueSplice = function(array, spliceIdx, spliceCount, newElems, parent) {
return array.splice.apply(array, spliceArgs);
};
var append = exports.append = _insert(function(dom, children, parent) {
exports.append = _insert(function(dom, children, parent) {
uniqueSplice(children, children.length, 0, dom, parent);
});
var prepend = exports.prepend = _insert(function(dom, children, parent) {
exports.prepend = _insert(function(dom, children, parent) {
uniqueSplice(children, 0, 0, dom, parent);
});
var after = exports.after = function() {
exports.after = function() {
var elems = slice.call(arguments),
dom = this._makeDomArray(elems),
self = this;
@@ -135,7 +134,7 @@ var after = exports.after = function() {
return this;
};
var before = exports.before = function() {
exports.before = function() {
var elems = slice.call(arguments),
dom = this._makeDomArray(elems),
self = this;
@@ -166,7 +165,7 @@ var before = exports.before = function() {
/*
remove([selector])
*/
var remove = exports.remove = function(selector) {
exports.remove = function(selector) {
var elems = this;
// Filter if we have selector
@@ -198,7 +197,7 @@ var remove = exports.remove = function(selector) {
return this;
};
var replaceWith = exports.replaceWith = function(content) {
exports.replaceWith = function(content) {
var self = this;
domEach(this, function(i, el) {
@@ -225,7 +224,7 @@ var replaceWith = exports.replaceWith = function(content) {
return this;
};
var empty = exports.empty = function() {
exports.empty = function() {
domEach(this, function(i, el) {
_.each(el.children, function(el) {
el.next = el.prev = el.parent = null;
@@ -239,7 +238,7 @@ var empty = exports.empty = function() {
/**
* Set/Get the HTML
*/
var html = exports.html = function(str) {
exports.html = function(str) {
if (str === undefined) {
if (!this[0] || !this[0].children) return null;
return $.html(this[0].children, this.options);
@@ -260,19 +259,19 @@ var html = exports.html = function(str) {
return this;
};
var toString = exports.toString = function() {
exports.toString = function() {
return $.html(this);
};
var text = exports.text = function(str) {
exports.text = function(str) {
// If `str` is undefined, act as a "getter"
if (str === undefined) {
return $.text(this);
} else if (typeof str === 'function') {
// Function support
return domEach(this, function(i, el) {
var $el = [el];
return text.call($el, str.call(el, i, $.text($el)));
return exports.text.call($el, str.call(el, i, $.text($el)));
});
}
@@ -297,7 +296,7 @@ var text = exports.text = function(str) {
return this;
};
var clone = exports.clone = function() {
exports.clone = function() {
// Turn it into HTML, then recreate it,
// Seems to be the easiest way to reconnect everything correctly
return this._make($.html(this));
Oops, something went wrong.

0 comments on commit ce39046

Please sign in to comment.