(layout: Layout, contextName: string)
| 466 | * @throw {Error} Validation error. |
| 467 | */ |
| 468 | export function validateLayout(layout: Layout, contextName: string): void { |
| 469 | contextName = contextName || "Layout"; |
| 470 | const subProps = ['x', 'y', 'w', 'h']; |
| 471 | let keyArr = []; |
| 472 | if (!Array.isArray(layout)) throw new Error(contextName + " must be an array!"); |
| 473 | for (let i = 0, len = layout.length; i < len; i++) { |
| 474 | const item = layout[i]; |
| 475 | for (let j = 0; j < subProps.length; j++) { |
| 476 | if (typeof item[subProps[j]] !== 'number') { |
| 477 | throw new Error('VueGridLayout: ' + contextName + '[' + i + '].' + subProps[j] + ' must be a number!'); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | if (item.i === undefined || item.i === null) { |
| 482 | throw new Error('VueGridLayout: ' + contextName + '[' + i + '].i cannot be null!'); |
| 483 | } |
| 484 | |
| 485 | if (typeof item.i !== 'number' && typeof item.i !== 'string') { |
| 486 | throw new Error('VueGridLayout: ' + contextName + '[' + i + '].i must be a string or number!'); |
| 487 | } |
| 488 | |
| 489 | if (keyArr.indexOf(item.i) >= 0) { |
| 490 | throw new Error('VueGridLayout: ' + contextName + '[' + i + '].i must be unique!'); |
| 491 | } |
| 492 | keyArr.push(item.i); |
| 493 | |
| 494 | if (item.static !== undefined && typeof item.static !== 'boolean') { |
| 495 | throw new Error('VueGridLayout: ' + contextName + '[' + i + '].static must be a boolean!'); |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | // Flow can't really figure this out, so we just use Object |
| 501 | export function autoBindHandlers(el: Object, fns: Array<string>): void { |
no outgoing calls
no test coverage detected
searching dependent graphs…