diff --git a/lib/api/attributes.js b/lib/api/attributes.js index 91094bef75..b08d24e602 100644 --- a/lib/api/attributes.js +++ b/lib/api/attributes.js @@ -11,6 +11,8 @@ var removeAttr = exports.removeAttr = function(name) { this.each(function() { $.removeAttr(this, name); }); + + return this; }; var hasClass = exports.hasClass = function(selector) { diff --git a/test/api.attributes.coffee b/test/api.attributes.coffee index ae7ed61498..f8eb17b15f 100644 --- a/test/api.attributes.coffee +++ b/test/api.attributes.coffee @@ -35,6 +35,7 @@ describe '$(...)', -> $pear = $('.pear', $fruits).attr('id', 'pear') $('#pear', $fruits).should.have.length 1 + should.exist $pear.cheerio it '(map) : object map should set multiple attributes', -> $fruits = $(fruits) @@ -47,7 +48,7 @@ describe '$(...)', -> attrs.id.should.equal 'apple' attrs.style.should.equal 'color:red;' attrs['data-url'].should.equal 'http://apple.com' - + describe '.removeAttr', -> it '(key) : should remove a single attr', -> @@ -57,7 +58,9 @@ describe '$(...)', -> $('ul', $fruits).removeAttr('id') should.not.exist $('ul', $fruits).attr('id') - + it 'should return cheerio object', -> + should.exist $('ul', fruits).removeAttr('id').cheerio + describe '.hasClass', -> it '(valid class) : should return true', ->