Merge "Use jQuery fake events for sticky header edit buttons"

This commit is contained in:
jenkins-bot 2023-06-05 20:52:14 +00:00 committed by Gerrit Code Review
commit 685d261647

View file

@ -290,12 +290,12 @@ function prepareEditIcons(
const $ve = $( primaryEdit ); const $ve = $( primaryEdit );
if ( target && $ve.length ) { if ( target && $ve.length ) {
const link = /** @type {HTMLAnchorElement} */( $ve[ 0 ] ); const link = /** @type {HTMLAnchorElement} */( $ve[ 0 ] );
const event = new Event( 'click' ); const event = $.Event( 'click' );
suffixStickyHref( link ); suffixStickyHref( link );
link.dispatchEvent( event ); $ve.trigger( event );
unsuffixStickyHref( link ); unsuffixStickyHref( link );
// The link has been progressively enhanced. // The link has been progressively enhanced.
if ( event.defaultPrevented ) { if ( event.isDefaultPrevented() ) {
disableStickyHeader(); disableStickyHeader();
ev.preventDefault(); ev.preventDefault();
} }
@ -310,12 +310,12 @@ function prepareEditIcons(
const $edit = $( secondaryEdit ); const $edit = $( secondaryEdit );
if ( $edit.length ) { if ( $edit.length ) {
const link = /** @type {HTMLAnchorElement} */( $edit[ 0 ] ); const link = /** @type {HTMLAnchorElement} */( $edit[ 0 ] );
const event = new Event( 'click' ); const event = $.Event( 'click' );
suffixStickyHref( link ); suffixStickyHref( link );
link.dispatchEvent( event ); $edit.trigger( event );
unsuffixStickyHref( link ); unsuffixStickyHref( link );
// The link has been progressively enhanced. // The link has been progressively enhanced.
if ( event.defaultPrevented ) { if ( event.isDefaultPrevented() ) {
disableStickyHeader(); disableStickyHeader();
ev.preventDefault(); ev.preventDefault();
} }