@@ -29,9 +29,6 @@ var SELF = wb.datamodel.Group = function WbDataModelGroup(
2929 if ( ! $ . isFunction ( GroupableCollectionConstructor ) ) {
3030 throw new Error ( 'Item container constructor needs to be a Function' ) ;
3131 }
32- if ( ! ( ( new GroupableCollectionConstructor ( ) ) instanceof wb . datamodel . GroupableCollection ) ) {
33- throw new Error ( 'Item container constructor needs to implement GroupableCollection' ) ;
34- }
3532 if ( ! $ . isFunction (
3633 GroupableCollectionConstructor . prototype [ groupableCollectionGetKeysFunctionName ]
3734 ) ) {
@@ -40,7 +37,6 @@ var SELF = wb.datamodel.Group = function WbDataModelGroup(
4037 }
4138
4239 this . _key = key ;
43- this . _GroupableCollectionConstructor = GroupableCollectionConstructor ;
4440 this . _groupableCollectionGetKeysFunctionName = groupableCollectionGetKeysFunctionName ;
4541 this . setItemContainer ( groupableCollection || new GroupableCollectionConstructor ( ) ) ;
4642} ;
@@ -52,12 +48,6 @@ $.extend( SELF.prototype, {
5248 */
5349 _key : null ,
5450
55- /**
56- * @property {Function }
57- * @private
58- */
59- _GroupableCollectionConstructor : null ,
60-
6151 /**
6252 * @property {string }
6353 * @private
@@ -81,8 +71,7 @@ $.extend( SELF.prototype, {
8171 * @return {wikibase.datamodel.GroupableCollection }
8272 */
8373 getItemContainer : function ( ) {
84- // Do not allow altering the encapsulated container.
85- return new this . _GroupableCollectionConstructor ( this . _groupableCollection . toArray ( ) ) ;
74+ return this . _groupableCollection ;
8675 } ,
8776
8877 /**
@@ -92,6 +81,10 @@ $.extend( SELF.prototype, {
9281 * match the key registered with the Group instance.
9382 */
9483 setItemContainer : function ( groupableCollection ) {
84+ if ( ! ( groupableCollection instanceof wb . datamodel . GroupableCollection ) ) {
85+ throw new Error ( 'groupableCollection must be a GroupableCollection' ) ;
86+ }
87+
9588 var keys = this . _getItemContainerKeys ( groupableCollection ) ;
9689
9790 for ( var i = 0 ; i < keys . length ; i ++ ) {
@@ -101,10 +94,7 @@ $.extend( SELF.prototype, {
10194 }
10295 }
10396
104- // Clone the container to prevent manipulation of the items using the original container.
105- this . _groupableCollection = new this . _GroupableCollectionConstructor (
106- groupableCollection . toArray ( )
107- ) ;
97+ this . _groupableCollection = groupableCollection ;
10898 } ,
10999
110100 /**
0 commit comments