@@ -462,6 +462,7 @@ export function synchronizeLayoutWithChildren(initialLayout: Layout, children: A
462
462
export function validateLayout ( layout : Layout , contextName : string ) : void {
463
463
contextName = contextName || "Layout" ;
464
464
const subProps = [ 'x' , 'y' , 'w' , 'h' ] ;
465
+ let keyArr = [ ] ;
465
466
if ( ! Array . isArray ( layout ) ) throw new Error ( contextName + " must be an array!" ) ;
466
467
for ( let i = 0 , len = layout . length ; i < len ; i ++ ) {
467
468
const item = layout [ i ] ;
@@ -470,11 +471,20 @@ export function validateLayout(layout: Layout, contextName: string): void {
470
471
throw new Error ( 'VueGridLayout: ' + contextName + '[' + i + '].' + subProps [ j ] + ' must be a number!' ) ;
471
472
}
472
473
}
473
- if ( item . i && typeof item . i !== 'string' ) {
474
- // number is also ok, so comment the error
475
- // TODO confirm if commenting the line below doesn't cause unexpected problems
476
- // throw new Error('VueGridLayout: ' + contextName + '[' + i + '].i must be a string!');
474
+
475
+ if ( item . i === undefined || item . i === null ) {
476
+ throw new Error ( 'VueGridLayout: ' + contextName + '[' + i + '].i cannot be null!' ) ;
477
+ }
478
+
479
+ if ( typeof item . i !== 'number' && typeof item . i !== 'string' ) {
480
+ throw new Error ( 'VueGridLayout: ' + contextName + '[' + i + '].i must be a string or number!' ) ;
477
481
}
482
+
483
+ if ( keyArr . indexOf ( item . i ) >= 0 ) {
484
+ throw new Error ( 'VueGridLayout: ' + contextName + '[' + i + '].i must be unique!' ) ;
485
+ }
486
+ keyArr . push ( item . i ) ;
487
+
478
488
if ( item . static !== undefined && typeof item . static !== 'boolean' ) {
479
489
throw new Error ( 'VueGridLayout: ' + contextName + '[' + i + '].static must be a boolean!' ) ;
480
490
}
0 commit comments