diff --git a/modules/ext.createwiki.oouiform.ooui.js b/modules/ext.createwiki.oouiform.ooui.js index 07706e91b7..2e6bf1f77e 100644 --- a/modules/ext.createwiki.oouiform.ooui.js +++ b/modules/ext.createwiki.oouiform.ooui.js @@ -6,6 +6,9 @@ tabs.$element.addClass( 'ext-createwiki-tabs-infused' ); function enhancePanel( panel ) { + if ( !panel || !panel.$element ) { + return; + } const $infuse = $( panel.$element ).find( '.ext-createwiki-infuse' ); $infuse.each( function () { try { @@ -82,7 +85,10 @@ if ( hash.match( /^#mw-[\w-]+/ ) ) { detectHash(); } else if ( hash === '' ) { - switchCreateWikiTab( $( '[id*=mw-section-]' ).attr( 'id' ), true ); + const $firstSection = $( '[id*=mw-section-]' ); + if ( $firstSection.length ) { + switchCreateWikiTab( $firstSection.attr( 'id' ), true ); + } } } ) // Run the function immediately to select the proper tab on startup.