Permalink
Browse files

Fix issue on Chrome, factorised body selectors

Closed #11
  • Loading branch information...
nico3333fr committed Jun 22, 2016
1 parent 40ca46d commit 20f127240437f918e938ec84d69f51ff98586002
Showing with 4 additions and 3 deletions.
  1. +4 −3 jquery-accessible-hide-show-aria.js
@@ -13,6 +13,7 @@ $(document).ready(function(){
attr_hidden = 'data-hidden',
$expandmore = $('.js-expandmore'),
$to_expand = $('.js-to_expand'),
+ $body = $('body'),
delay = 1500;
@@ -55,7 +56,7 @@ $(document).ready(function(){
}
- $( 'body' ).on( 'click', '.js-expandmore-button', function( event ) {
+ $body.on( 'click', '.js-expandmore-button', function( event ) {
var $this = $(this),
$destination = $( '#' + $this.attr(attr_control) );
@@ -72,12 +73,12 @@ $(document).ready(function(){
});
- $( 'body' ).on( 'click keydown', '.js-expandmore', function( event ) {
+ $body.on( 'click keydown', '.js-expandmore', function( event ) {
var $this = $(this),
$target = $(event.target),
$button_in = $this.find( '.js-expandmore-button' );
- if ( !$target.is($button_in) ) {
+ if ( !$target.is($button_in) && !$target.closest($button_in).length ) {
if ( event.type == 'click' ){
$button_in.trigger('click');

0 comments on commit 20f1272

Please sign in to comment.