(id, idPath, rawProp, cls, callbacks)
| 541 | } |
| 542 | |
| 543 | function validateProp(id, idPath, rawProp, cls, callbacks) { |
| 544 | const prop = rawProp.split('@')[0]; |
| 545 | const component = path(idPath, layout); |
| 546 | const element = Registry.resolve(component); |
| 547 | |
| 548 | // note: Flow components do not have propTypes, so we can't validate. |
| 549 | if (element && element.propTypes && !element.propTypes[prop]) { |
| 550 | // look for wildcard props (ie data-* etc) |
| 551 | for (const propName in element.propTypes) { |
| 552 | const last = propName.length - 1; |
| 553 | if ( |
| 554 | propName.charAt(last) === '*' && |
| 555 | prop.substr(0, last) === propName.substr(0, last) |
| 556 | ) { |
| 557 | return; |
| 558 | } |
| 559 | } |
| 560 | const {type, namespace} = component; |
| 561 | dispatchError('Invalid prop for this component', [ |
| 562 | `Property "${prop}" was used with component ID:`, |
| 563 | ` ${JSON.stringify(id)}`, |
| 564 | `in one of the ${cls} items of a callback.`, |
| 565 | `This ID is assigned to a ${namespace}.${type} component`, |
| 566 | 'in the layout, which does not support this property.', |
| 567 | tail(callbacks) |
| 568 | ]); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | function validateIdPatternProp(id, property, cls, callbacks) { |
| 573 | resolveDeps()(paths)({id, property}).forEach(dep => { |
no test coverage detected
searching dependent graphs…