Skip to content

Commit

Permalink
$.fn.removeAttr: ensuring a collection containing non-element objects…
Browse files Browse the repository at this point in the history
… doesn’t cause an error to be thrown
  • Loading branch information
fabiospampinato committed Jan 3, 2020
1 parent 5f1c9c9 commit 2230646
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/attributes/remove_attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fn.removeAttr = function ( this: Cash, attr: string ) {

return this.each ( ( i, ele ) => {

if ( !isElement ( ele ) ) return;

each ( attrs, ( i, a ) => {

ele.removeAttribute ( a );
Expand Down
10 changes: 10 additions & 0 deletions test/modules/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ describe ( 'Attributes', { beforeEach: getFixtureInit ( fixture ) }, function ()

});

it ( 'supports collections containing non-elements objects', function ( t ) {

var ele = $(document.createTextNode ( '.css' ));

ele.removeAttr ( 'foo' );

t.pass ();

});

});

describe ( '$.fn.removeClass', function ( it ) {
Expand Down

0 comments on commit 2230646

Please sign in to comment.