jenkins-bot has submitted this change and it was merged.
Change subject: Remove singular adding for ve.ui.GroupElement
......................................................................
Remove singular adding for ve.ui.GroupElement
By making the API for adding/removing/clearing always plural, it greatly
simplifies the interfaces and reduces function call overhead in most
situations.
Change-Id: Ia8f23a373a01a8f6d5081587a591563e4f25ea42
---
M modules/ve/ui/elements/ve.ui.GroupElement.js
1 file changed, 12 insertions(+), 21 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ui/elements/ve.ui.GroupElement.js
b/modules/ve/ui/elements/ve.ui.GroupElement.js
index eec22df..9a0fed5 100644
--- a/modules/ve/ui/elements/ve.ui.GroupElement.js
+++ b/modules/ve/ui/elements/ve.ui.GroupElement.js
@@ -41,29 +41,20 @@
* @chainable
*/
ve.ui.GroupElement.prototype.addItems = function ( items ) {
- var i, len;
- for ( i = 0, len = items.length; i < len; i++ ) {
- this.addItem( items[i] );
- }
- return this;
-};
+ var i, len, item;
-/**
- * Add item.
- *
- * @method
- * @param {ve.ui.Widget} item Item
- * @chainable
- */
-ve.ui.GroupElement.prototype.addItem = function ( item ) {
- // Check if item exists then remove it first, effectively "moving" it
- if ( this.items.indexOf( item ) !== -1 ) {
- this.removeItems( [item] );
+ for ( i = 0, len = items.length; i < len; i++ ) {
+ item = items[i];
+
+ // Check if item exists then remove it first, effectively
"moving" it
+ if ( this.items.indexOf( item ) !== -1 ) {
+ this.removeItems( [item] );
+ }
+ // Add the item
+ this.items.push( item );
+ this.$.append( item.$ );
+ this.$items = this.$items.add( item.$ );
}
- // Add the item
- this.items.push( item );
- this.$.append( item.$ );
- this.$items = this.$items.add( item.$ );
return this;
};
--
To view, visit https://gerrit.wikimedia.org/r/61473
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia8f23a373a01a8f6d5081587a591563e4f25ea42
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits