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

Function bindAttributeOutsideSvg

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

Source from the content-addressed store, hash-verified

727 // `hostElement` keeps the tag name out of the template, which lets the cases below be table
728 // driven. Returns the change detection call so the caller can assert on it.
729 function bindAttributeOutsideSvg(
730 tagName: string,
731 attrName: keyof typeof attrCarriers,
732 staticAttributeName: string,
733 ): () => void {
734 @Component({
735 template: '',
736 changeDetection: ChangeDetectionStrategy.Eager,
737 })
738 class DynamicHost {}
739
740 const hostElement = document.createElement(tagName);
741 hostElement.setAttribute('attributeName', staticAttributeName);
742
743 const componentRef = createComponent(DynamicHost, {
744 hostElement,
745 environmentInjector: TestBed.inject(EnvironmentInjector),
746 directives: [attrCarriers[attrName]],
747 });
748
749 return () => {
750 try {
751 componentRef.changeDetectorRef.detectChanges();
752 } finally {
753 componentRef.destroy();
754 }
755 };
756 }
757
758 // An animation element declared outside of an `<svg>` is created in the HTML namespace, but still
759 // 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