Skip to content

Commit

Permalink
$.fn.hide|show|toggle: ensuring a collection containing non-element o…
Browse files Browse the repository at this point in the history
…bjects doesn’t case an error to be thrown
  • Loading branch information
fabiospampinato committed Dec 30, 2019
1 parent f82e06e commit dc8e956
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/effects/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fn.toggle = function ( this: Cash, force?: boolean ) {

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

if ( !isElement ( ele ) ) return;

const show = isUndefined ( force ) ? isHidden ( ele ) : force;

if ( show ) {
Expand Down
10 changes: 10 additions & 0 deletions test/modules/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ describe ( 'Effects', { beforeEach: getFixtureInit ( fixture ) }, function () {

});

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

var eles = $('.shown');

eles.toggle ().toggle ().toggle ().toggle ();

t.pass ();

});

});

});

0 comments on commit dc8e956

Please sign in to comment.