Permalink
Browse files

Merge "jquery.makeCollapsible: Restore considering empty <a> as part …

…of toggle"
  • Loading branch information...
jenkins-bot Gerrit Code Review
jenkins-bot authored and Gerrit Code Review committed May 25, 2017
2 parents 62a1d96 + 15b88fc commit f0e12ae951ef9f6cb359c5ecfcd3739e38f4d29a
@@ -152,7 +152,8 @@
if ( e ) {
if (
e.type === 'click' &&
e.target.nodeName.toLowerCase() === 'a'
e.target.nodeName.toLowerCase() === 'a' &&
$( e.target ).attr( 'href' )
) {
// Don't fire if a link was clicked (for premade togglers)
return;
@@ -266,7 +266,7 @@
var $collapsible = prepareCollapsible(
'<div class="mw-collapsible">' +
'<div class="mw-collapsible-toggle">' +
'Toggle <a href="#">toggle</a> toggle <b>toggle</b>' +
'Toggle <a href="#top">toggle</a> toggle <b>toggle</b>' +
'</div>' +
'<div class="mw-collapsible-content">' + loremIpsum + '</div>' +
'</div>',
@@ -282,6 +282,22 @@
assert.assertTrue( $content.is( ':hidden' ), 'click event on non-link inside toggle toggles content' );
} );
QUnit.test( 'click on non-link inside toggler counts as trigger', function ( assert ) {
var $collapsible = prepareCollapsible(
'<div class="mw-collapsible">' +
'<div class="mw-collapsible-toggle">' +
'Toggle <a>toggle</a> toggle <b>toggle</b>' +
'</div>' +
'<div class="mw-collapsible-content">' + loremIpsum + '</div>' +
'</div>',
{ instantHide: true }
),
$content = $collapsible.find( '.mw-collapsible-content' );
$collapsible.find( '.mw-collapsible-toggle a' ).trigger( 'click' );
assert.assertTrue( $content.is( ':hidden' ), 'click event on link (with no href) inside toggle toggles content' );
} );
QUnit.test( 'collapse/expand text (data-collapsetext, data-expandtext)', function ( assert ) {
var $collapsible = prepareCollapsible(
'<div class="mw-collapsible" data-collapsetext="Collapse me!" data-expandtext="Expand me!">' +

0 comments on commit f0e12ae

Please sign in to comment.