... And they should be.
We trust all over our widgets that going "this.addItems( ... )" is a no-op if the given item is null, and it is a reordering process if the item already exists. However, as @kostajh found out, that's not true;
Example:
OO.ui.mixin.GroupElement.prototype.removeItems = function ( items ) { var i, len, item, index; // Remove specific items elements for ( i = 0, len = items.length; i < len; i++ ) { item = items[ i ]; index = this.items.indexOf( item ); if ( index !== -1 ) { item.setElementGroup( null ); item.$element.detach(); } } // Mixin method OO.EmitterList.prototype.removeItems.call( this, items ); this.emit( 'change', this.getItems() ); return this; };
https://github.com/wikimedia/oojs-ui/blob/825593aee9/src/mixins/GroupElement.js#L180
The 'removeItems' process emits 'change' event even if there were no items at all. This produces problems for other widgets, like TagMultiselectWidget's "addTag" routine where if a tag isn't actually added in, the change event is still emitted, which causes a resizing process to happen and a reflow.
If the assumption is that GroupElement's methods are safe for no-op when no items are given, we should make sure that's actually true in the code.