mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
Rewrite a conditional to make the logic a little clearer.
I spent a couple minutes looking at this before I saw that we needed `this.updateVisibility()` to only fire if the loop iterated at least once. Change-Id: I7d03f73a35e3ded539898effa064dc0e14ba595f
This commit is contained in:
parent
12ef5b7471
commit
652e140dc5
|
@ -96,23 +96,22 @@ ve.ui.MWTocWidget.prototype.onMetaListRemove = function ( metaItem ) {
|
|||
* Initialize TOC based on the presence of magic words
|
||||
*/
|
||||
ve.ui.MWTocWidget.prototype.initFromMetaList = function () {
|
||||
const items = this.metaList.getItemsInGroup( 'mwTOC' ),
|
||||
len = items.length;
|
||||
let i = 0;
|
||||
if ( len > 0 ) {
|
||||
for ( ; i < len; i++ ) {
|
||||
if ( items[ i ] instanceof ve.dm.MWTOCMetaItem ) {
|
||||
const property = items[ i ].getAttribute( 'property' );
|
||||
if ( property === 'mw:PageProp/forcetoc' ) {
|
||||
this.mwTOCForce = true;
|
||||
}
|
||||
if ( property === 'mw:PageProp/notoc' ) {
|
||||
this.mwTOCDisable = true;
|
||||
}
|
||||
const items = this.metaList.getItemsInGroup( 'mwTOC' );
|
||||
if ( items.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
for ( let i = 0; i < items.length; i++ ) {
|
||||
if ( items[ i ] instanceof ve.dm.MWTOCMetaItem ) {
|
||||
const property = items[ i ].getAttribute( 'property' );
|
||||
if ( property === 'mw:PageProp/forcetoc' ) {
|
||||
this.mwTOCForce = true;
|
||||
}
|
||||
if ( property === 'mw:PageProp/notoc' ) {
|
||||
this.mwTOCDisable = true;
|
||||
}
|
||||
}
|
||||
this.updateVisibility();
|
||||
}
|
||||
this.updateVisibility();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue