@@ -29,9 +29,6 @@ var SELF = wb.datamodel.Group = function WbDataModelGroup(
29
29
if ( ! $ . isFunction ( GroupableCollectionConstructor ) ) {
30
30
throw new Error ( 'Item container constructor needs to be a Function' ) ;
31
31
}
32
- if ( ! ( ( new GroupableCollectionConstructor ( ) ) instanceof wb . datamodel . GroupableCollection ) ) {
33
- throw new Error ( 'Item container constructor needs to implement GroupableCollection' ) ;
34
- }
35
32
if ( ! $ . isFunction (
36
33
GroupableCollectionConstructor . prototype [ groupableCollectionGetKeysFunctionName ]
37
34
) ) {
@@ -40,7 +37,6 @@ var SELF = wb.datamodel.Group = function WbDataModelGroup(
40
37
}
41
38
42
39
this . _key = key ;
43
- this . _GroupableCollectionConstructor = GroupableCollectionConstructor ;
44
40
this . _groupableCollectionGetKeysFunctionName = groupableCollectionGetKeysFunctionName ;
45
41
this . setItemContainer ( groupableCollection || new GroupableCollectionConstructor ( ) ) ;
46
42
} ;
@@ -52,12 +48,6 @@ $.extend( SELF.prototype, {
52
48
*/
53
49
_key : null ,
54
50
55
- /**
56
- * @property {Function }
57
- * @private
58
- */
59
- _GroupableCollectionConstructor : null ,
60
-
61
51
/**
62
52
* @property {string }
63
53
* @private
@@ -81,8 +71,7 @@ $.extend( SELF.prototype, {
81
71
* @return {wikibase.datamodel.GroupableCollection }
82
72
*/
83
73
getItemContainer : function ( ) {
84
- // Do not allow altering the encapsulated container.
85
- return new this . _GroupableCollectionConstructor ( this . _groupableCollection . toArray ( ) ) ;
74
+ return this . _groupableCollection ;
86
75
} ,
87
76
88
77
/**
@@ -92,6 +81,10 @@ $.extend( SELF.prototype, {
92
81
* match the key registered with the Group instance.
93
82
*/
94
83
setItemContainer : function ( groupableCollection ) {
84
+ if ( ! ( groupableCollection instanceof wb . datamodel . GroupableCollection ) ) {
85
+ throw new Error ( 'groupableCollection must be a GroupableCollection' ) ;
86
+ }
87
+
95
88
var keys = this . _getItemContainerKeys ( groupableCollection ) ;
96
89
97
90
for ( var i = 0 ; i < keys . length ; i ++ ) {
@@ -101,10 +94,7 @@ $.extend( SELF.prototype, {
101
94
}
102
95
}
103
96
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 ;
108
98
} ,
109
99
110
100
/**
0 commit comments