Bmansurov has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/368834 )

Change subject: Make sure lead section exists before accessing its method
......................................................................

Make sure lead section exists before accessing its method

The `getLeadSectionElement` method of `Page` may return a `null`. Do
not try to access the `text` method of the returned object if it's
`null`.

Bug: T157995
Change-Id: Ia752fa52d1b09a307dc4b803a6b7e1bdcfe7f867
---
M resources/skins.minerva.editor/init.js
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/MinervaNeue 
refs/changes/34/368834/1

diff --git a/resources/skins.minerva.editor/init.js 
b/resources/skins.minerva.editor/init.js
index f7e8b3b..1def74e 100644
--- a/resources/skins.minerva.editor/init.js
+++ b/resources/skins.minerva.editor/init.js
@@ -123,7 +123,8 @@
         * @param {Page} page The page to edit.
         */
        function setupEditor( page ) {
-               var isNewPage = page.options.id === 0;
+               var isNewPage = page.options.id === 0,
+                       leadSection = page.getLeadSectionElement();
 
                if ( mw.util.getParamValue( 'undo' ) ) {
                        // TODO: Replace with an OOUI dialog
@@ -249,11 +250,11 @@
                        $( '.nojs-edit' ).removeClass( 'nojs-edit' );
                        $( '#ca-edit a' ).remove();
                        // FIXME: unfortunately the main page is special cased.
-                       if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || 
page.getLeadSectionElement().text() ) {
+                       if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || ( 
leadSection && leadSection.text() ) ) {
                                // if lead section is not empty, open editor 
with lead section
                                addEditButton( 0, '#ca-edit' );
                        } else {
-                               // if lead section is empty, open editor with 
first section
+                               // if lead section is empty or does not exist, 
open editor with first section
                                addEditButton( 1, '#ca-edit' );
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/368834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia752fa52d1b09a307dc4b803a6b7e1bdcfe7f867
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/MinervaNeue
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to