MCPcopy Index your code
hub / github.com/angular/angular / validateNoEventBindings

Function validateNoEventBindings

packages/compiler/src/render3/view/compiler.ts:603–624  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

601 * @param sourceSpan - Source span where the host bindings were defined.
602 */
603function 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
626function compileStyles(styles: string[], selector: string, hostSelector: string): string[] {
627 const shadowCss = new ShadowCss();

Callers 1

verifyHostBindingsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…