MCPcopy Create free account
hub / github.com/angular/angular / bindAttributeOutsideSvg

Function bindAttributeOutsideSvg

packages/core/test/render3/integration_spec.ts:714–740  ·  view source on GitHub ↗
(
    tagName: string,
    attrName: keyof typeof attrCarriers,
    staticAttributeName: string,
  )

Source from the content-addressed store, hash-verified

712 // `hostElement` keeps the tag name out of the template, which lets the cases below be table
713 // driven. Returns the change detection call so the caller can assert on it.
714 function bindAttributeOutsideSvg(
715 tagName: string,
716 attrName: keyof typeof attrCarriers,
717 staticAttributeName: string,
718 ): () => void {
719 @Component({
720 template: '',
721 })
722 class DynamicHost {}
723
724 const hostElement = document.createElement(tagName);
725 hostElement.setAttribute('attributeName', staticAttributeName);
726
727 const componentRef = createComponent(DynamicHost, {
728 hostElement,
729 environmentInjector: TestBed.inject(EnvironmentInjector),
730 directives: [attrCarriers[attrName]],
731 });
732
733 return () => {
734 try {
735 componentRef.changeDetectorRef.detectChanges();
736 } finally {
737 componentRef.destroy();
738 }
739 };
740 }
741
742 // An animation element declared outside of an `<svg>` is created in the HTML namespace, but still
743 // animates once it ends up inside an `<svg>` subtree - for example when it is projected into one

Callers 1

Calls 6

createComponentFunction · 0.90
createElementMethod · 0.65
setAttributeMethod · 0.65
injectMethod · 0.65
destroyMethod · 0.65
detectChangesMethod · 0.45

Tested by

no test coverage detected