Skip to content

Commit

Permalink
Merge pull request tj#174 from tonylukasavage/jQuery_check
Browse files Browse the repository at this point in the history
Fixes jQuery checks in environments without DOM
  • Loading branch information
btd committed Jan 28, 2014
2 parents cd3b57a + 74e181c commit d621d5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
22 changes: 12 additions & 10 deletions lib/ext/browser/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ module.exports = function(should, Assertion) {
};
}

jQuery.fn.inspect = function () {
var elementList = this.toArray().map(function (e) {
return util.inspect(e);
}).join(", ");
if (this.selector) {
return "SELECTOR(" + this.selector + ") matching " + this.length + " elements" + (elementList.length ? ": " + elementList : "");
} else {
return elementList;
}
};
if (typeof jQuery !== "undefined" && jQuery && !jQuery.prototype.inspect) {
jQuery.fn.inspect = function () {
var elementList = this.toArray().map(function (e) {
return util.inspect(e);
}).join(", ");
if (this.selector) {
return "SELECTOR(" + this.selector + ") matching " + this.length + " elements" + (elementList.length ? ": " + elementList : "");
} else {
return elementList;
}
};
}

function jQueryAttributeTestHelper(method, singular, plural, nameOrHash, value) {
var keys = util.isObject(nameOrHash) ? Object.keys(nameOrHash) : [nameOrHash];
Expand Down
22 changes: 12 additions & 10 deletions should.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,18 @@ module.exports = function(should, Assertion) {
};
}

jQuery.fn.inspect = function () {
var elementList = this.toArray().map(function (e) {
return util.inspect(e);
}).join(", ");
if (this.selector) {
return "SELECTOR(" + this.selector + ") matching " + this.length + " elements" + (elementList.length ? ": " + elementList : "");
} else {
return elementList;
}
};
if (typeof jQuery !== "undefined" && jQuery && !jQuery.prototype.inspect) {
jQuery.fn.inspect = function () {
var elementList = this.toArray().map(function (e) {
return util.inspect(e);
}).join(", ");
if (this.selector) {
return "SELECTOR(" + this.selector + ") matching " + this.length + " elements" + (elementList.length ? ": " + elementList : "");
} else {
return elementList;
}
};
}

function jQueryAttributeTestHelper(method, singular, plural, nameOrHash, value) {
var keys = util.isObject(nameOrHash) ? Object.keys(nameOrHash) : [nameOrHash];
Expand Down

0 comments on commit d621d5c

Please sign in to comment.