mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 09:04:21 +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,11 +96,11 @@ 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++ ) {
|
||||
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' ) {
|
||||
|
@ -112,7 +112,6 @@ ve.ui.MWTocWidget.prototype.initFromMetaList = function () {
|
|||
}
|
||||
}
|
||||
this.updateVisibility();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue