Avoid error if watchlist has been toggled before editing

onWatchToggle didn't cope with the case where there was already an event
in the hook-queue when it was registered during setup

Bug: T328955
Change-Id: Ic80f707e86ba3c9f88097cac8aec8c6b3cc32cee
This commit is contained in:
David Lynch 2023-02-06 15:58:45 -06:00
parent 8eb272c2be
commit d8fd73d72a

View file

@ -368,7 +368,7 @@ ve.init.mw.DesktopArticleTarget.prototype.onWatchToggle = function ( isWatched )
if ( !this.active && !this.activating ) {
return;
}
if ( this.checkboxesByName.wpWatchthis ) {
if ( this.checkboxesByName && this.checkboxesByName.wpWatchthis ) {
this.checkboxesByName.wpWatchthis.setSelected(
!!mw.user.options.get( 'watchdefault' ) ||
( !!mw.user.options.get( 'watchcreations' ) && !this.pageExists ) ||