* Validates that there are no event attribute bindings in the host bindings. * @param bindings - Map of host bindings for the component. * @param bindingParser - Binding parser used to create the binding expression. * @param sourceSpan - Source span where the host bindings were defined.
( bindings: ParsedHostBindings, bindingParser: BindingParser, sourceSpan: ParseSourceSpan, )
| 601 | * @param sourceSpan - Source span where the host bindings were defined. |
| 602 | */ |
| 603 | function validateNoEventBindings( |
| 604 | bindings: ParsedHostBindings, |
| 605 | bindingParser: BindingParser, |
| 606 | sourceSpan: ParseSourceSpan, |
| 607 | ): void { |
| 608 | for (const prop in bindings.properties) { |
| 609 | const isAttr = prop.startsWith('attr.'); |
| 610 | const boundName = isAttr ? prop.slice(5) : prop; |
| 611 | |
| 612 | if (boundName.toLowerCase().startsWith('on')) { |
| 613 | const errorType = isAttr ? 'attribute' : 'property'; |
| 614 | const suggestion = `(${boundName.slice(2)})=...`; |
| 615 | |
| 616 | let msg = `Binding to event ${errorType} '${boundName}' is disallowed for security reasons, please use ${suggestion}`; |
| 617 | if (!isAttr) { |
| 618 | msg += `\nIf '${prop}' is a directive input, make sure the directive is imported by the current module.`; |
| 619 | } |
| 620 | |
| 621 | bindingParser.errors.push(new ParseError(sourceSpan, msg)); |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | function compileStyles(styles: string[], selector: string, hostSelector: string): string[] { |
| 627 | const shadowCss = new ShadowCss(); |
no test coverage detected
searching dependent graphs…