Skip to content

Commit

Permalink
fix: edit focus assertion to avoid monkey-patching jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
t1st3 committed Nov 8, 2015
1 parent 11ddaf9 commit 3467388
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions chai-jquery.js
Expand Up @@ -230,18 +230,10 @@
);

chai.Assertion.addMethod('focus', function () {
// workaround for Webkit-based browsers
// see https://github.com/ariya/phantomjs/issues/10427
var _jQuery_is = $.fn.is;
$.fn.is = function(s) {
if (s === ':focus') {
return this.get(0) === document.activeElement;
}
return _jQuery_is.apply(this, arguments);
};

this.assert(
flag(this, 'object').is(':focus')
// Can't use `$().is(':focus')` because of certain webkit browsers
// see https://github.com/ariya/phantomjs/issues/10427
flag(this, 'object').get(0) === document.activeElement
, 'expected #{this} to have focus'
, 'expected #{this} not to have focus');
});
Expand Down

0 comments on commit 3467388

Please sign in to comment.