diff --git a/projects/angular/src/data/datagrid/wrapped-cell.ts b/projects/angular/src/data/datagrid/wrapped-cell.ts index 5f16b58511..d920013d09 100644 --- a/projects/angular/src/data/datagrid/wrapped-cell.ts +++ b/projects/angular/src/data/datagrid/wrapped-cell.ts @@ -7,8 +7,6 @@ import { AfterViewInit, Component, EmbeddedViewRef, OnDestroy, TemplateRef, ViewChild } from '@angular/core'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; - @Component({ selector: 'dg-wrapped-cell', template: ` @@ -17,8 +15,7 @@ import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; `, }) -export class WrappedCell implements DynamicWrapper, AfterViewInit, OnDestroy { - _dynamic = false; +export class WrappedCell implements AfterViewInit, OnDestroy { @ViewChild('cellPortal') templateRef: TemplateRef; cellView: EmbeddedViewRef; // the cells projected view diff --git a/projects/angular/src/data/datagrid/wrapped-column.ts b/projects/angular/src/data/datagrid/wrapped-column.ts index f2a0146de8..f5d7267cf3 100644 --- a/projects/angular/src/data/datagrid/wrapped-column.ts +++ b/projects/angular/src/data/datagrid/wrapped-column.ts @@ -7,8 +7,6 @@ import { AfterViewInit, Component, EmbeddedViewRef, OnDestroy, TemplateRef, ViewChild } from '@angular/core'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; - @Component({ selector: 'dg-wrapped-column', template: ` @@ -17,9 +15,7 @@ import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; `, }) -export class WrappedColumn implements DynamicWrapper, AfterViewInit, OnDestroy { - _dynamic = false; - +export class WrappedColumn implements AfterViewInit, OnDestroy { @ViewChild('columnPortal') templateRef: TemplateRef; columnView: EmbeddedViewRef; // the columns projected view (in memory) diff --git a/projects/angular/src/data/datagrid/wrapped-row.ts b/projects/angular/src/data/datagrid/wrapped-row.ts index 62ba0ab65c..832750a2e7 100644 --- a/projects/angular/src/data/datagrid/wrapped-row.ts +++ b/projects/angular/src/data/datagrid/wrapped-row.ts @@ -7,8 +7,6 @@ import { AfterViewInit, Component, EmbeddedViewRef, OnDestroy, TemplateRef, ViewChild } from '@angular/core'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; - @Component({ selector: 'dg-wrapped-row', template: ` @@ -17,9 +15,7 @@ import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; `, }) -export class WrappedRow implements DynamicWrapper, AfterViewInit, OnDestroy { - _dynamic = false; - +export class WrappedRow implements AfterViewInit, OnDestroy { @ViewChild('rowPortal') templateRef: TemplateRef; rowView: EmbeddedViewRef; // the rows projected view (in memory) diff --git a/projects/angular/src/forms/checkbox/checkbox-wrapper.ts b/projects/angular/src/forms/checkbox/checkbox-wrapper.ts index c6438d142b..663e87e9fd 100644 --- a/projects/angular/src/forms/checkbox/checkbox-wrapper.ts +++ b/projects/angular/src/forms/checkbox/checkbox-wrapper.ts @@ -8,7 +8,6 @@ import { Component, ContentChild, Inject, InjectionToken, OnDestroy, OnInit } from '@angular/core'; import { BehaviorSubject, Subscription } from 'rxjs'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { ClrLabel } from '../common/label'; import { ControlIdService } from '../common/providers/control-id.service'; @@ -31,11 +30,7 @@ export const IS_TOGGLE_PROVIDER = { provide: IS_TOGGLE, useFactory: isToggleFact }, providers: [ControlIdService, IS_TOGGLE_PROVIDER], }) -export class ClrCheckboxWrapper implements DynamicWrapper, OnInit, OnDestroy { - // We need both _dynamic for HostWrapper and ContentChild(ClrLabel) in cases where - // the user puts a radio inside a wrapper without a label, host wrapping doesn't apply - // but we'd still need to insert a label - _dynamic = false; +export class ClrCheckboxWrapper implements OnInit, OnDestroy { @ContentChild(ClrLabel, { static: true }) label: ClrLabel; toggle = false; private subscriptions: Subscription[] = []; diff --git a/projects/angular/src/forms/common/abstract-container.ts b/projects/angular/src/forms/common/abstract-container.ts index b7dff49aa3..61245444e6 100644 --- a/projects/angular/src/forms/common/abstract-container.ts +++ b/projects/angular/src/forms/common/abstract-container.ts @@ -9,7 +9,6 @@ import { AfterContentInit, ContentChild, Directive, OnDestroy, Optional } from ' import { NgControl } from '@angular/forms'; import { Subscription } from 'rxjs'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { ClrControlError } from './error'; import { ClrControlHelper } from './helper'; import { CONTROL_STATE, IfControlStateService } from './if-control-state/if-control-state.service'; @@ -20,14 +19,13 @@ import { NgControlService } from './providers/ng-control.service'; import { ClrControlSuccess } from './success'; @Directive() -export abstract class ClrAbstractContainer implements DynamicWrapper, OnDestroy, AfterContentInit { +export abstract class ClrAbstractContainer implements OnDestroy, AfterContentInit { @ContentChild(ClrLabel, { static: false }) label: ClrLabel; @ContentChild(ClrControlSuccess) controlSuccessComponent: ClrControlSuccess; @ContentChild(ClrControlError) controlErrorComponent: ClrControlError; @ContentChild(ClrControlHelper) controlHelperComponent: ClrControlHelper; control: NgControl; - _dynamic = false; protected subscriptions: Subscription[] = []; diff --git a/projects/angular/src/forms/common/common.spec.ts b/projects/angular/src/forms/common/common.spec.ts index ac36e452e4..4dace84032 100644 --- a/projects/angular/src/forms/common/common.spec.ts +++ b/projects/angular/src/forms/common/common.spec.ts @@ -9,7 +9,6 @@ import { Component, Directive, NgModule, Type, ViewContainerRef } from '@angular import { TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { ClrHostWrappingModule } from '../../utils/host-wrapping/host-wrapping.module'; import { ClrCommonFormsModule } from './common.module'; import { ControlIdService } from './providers/control-id.service'; @@ -27,9 +26,7 @@ import { WrappedFormControl } from './wrapped-control'; `, providers: [ControlIdService], }) -class GenericWrapper implements DynamicWrapper { - _dynamic = false; -} +class GenericWrapper {} @Directive({ selector: '[genericControl]', diff --git a/projects/angular/src/forms/common/wrapped-control.spec.ts b/projects/angular/src/forms/common/wrapped-control.spec.ts index f6de195941..96ea99ccb8 100644 --- a/projects/angular/src/forms/common/wrapped-control.spec.ts +++ b/projects/angular/src/forms/common/wrapped-control.spec.ts @@ -10,7 +10,6 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { FormControl, FormGroup, FormsModule, NgControl, ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { HostWrapper } from '../../utils/host-wrapping/host-wrapper'; import { ClrHostWrappingModule } from '../../utils/host-wrapping/host-wrapping.module'; import { ClrAbstractContainer } from './abstract-container'; @@ -33,9 +32,7 @@ import { WrappedFormControl } from './wrapped-control'; template: ``, providers: [ControlIdService], }) -class TestWrapper implements DynamicWrapper { - _dynamic = false; -} +class TestWrapper {} @Directive({ selector: '[testControl]', @@ -54,9 +51,7 @@ class TestControl extends WrappedFormControl { `, providers: [ControlIdService], }) -class TestWrapper2 implements DynamicWrapper { - _dynamic = false; -} +class TestWrapper2 {} @Directive({ selector: '[testControl2]', @@ -72,9 +67,7 @@ class TestControl2 extends WrappedFormControl { template: `
`, providers: [ControlIdService, NgControlService, IfControlStateService, ControlClassService], }) -class TestWrapper3 extends ClrAbstractContainer implements DynamicWrapper { - _dynamic = false; -} +class TestWrapper3 extends ClrAbstractContainer {} @Directive({ selector: '[testControl3]', @@ -297,7 +290,6 @@ export default function (): void { spyOn(HostWrapper.prototype, 'get').and.callThrough(); setupTest(this, WithWrapperNoId, TestControl); expect(HostWrapper.prototype.get).toHaveBeenCalledWith(ControlIdService); - expect(this.wrapper._dynamic).toBe(false); }); it('sets the id of the host to the id given by the service', function (this: TestContext) { @@ -317,7 +309,6 @@ export default function (): void { spyOn(HostWrapper.prototype, 'get').and.callThrough(); setupTest(this, NoWrapperNoId, TestControl); expect(HostWrapper.prototype.get).toHaveBeenCalledWith(ControlIdService); - expect(this.wrapper._dynamic).toBe(true); }); it('sets the id of the host to the id given by the service', function (this: TestContext) { diff --git a/projects/angular/src/forms/common/wrapped-control.ts b/projects/angular/src/forms/common/wrapped-control.ts index e709c8b1e7..ab6f5ff771 100644 --- a/projects/angular/src/forms/common/wrapped-control.ts +++ b/projects/angular/src/forms/common/wrapped-control.ts @@ -25,7 +25,6 @@ import { import { NgControl } from '@angular/forms'; import { Subscription } from 'rxjs'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { HostWrapper } from '../../utils/host-wrapping/host-wrapper'; import { CONTROL_SUFFIX } from './abstract-control'; import { IfControlStateService } from './if-control-state/if-control-state.service'; @@ -41,7 +40,7 @@ export enum CHANGE_KEYS { } @Directive() -export class WrappedFormControl implements OnInit, DoCheck, OnDestroy { +export class WrappedFormControl implements OnInit, DoCheck, OnDestroy { _id: string; protected controlIdService: ControlIdService; diff --git a/projects/angular/src/forms/radio/radio-wrapper.ts b/projects/angular/src/forms/radio/radio-wrapper.ts index 4efac6ecc5..ae3b3be807 100644 --- a/projects/angular/src/forms/radio/radio-wrapper.ts +++ b/projects/angular/src/forms/radio/radio-wrapper.ts @@ -7,7 +7,6 @@ import { Component, ContentChild, OnInit } from '@angular/core'; -import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper'; import { ClrLabel } from '../common/label'; import { ControlIdService } from '../common/providers/control-id.service'; @@ -23,11 +22,7 @@ import { ControlIdService } from '../common/providers/control-id.service'; }, providers: [ControlIdService], }) -export class ClrRadioWrapper implements DynamicWrapper, OnInit { - // We need both _dynamic for HostWrapper and ContentChild(ClrLabel) in cases where - // the user puts a radio inside a wrapper without a label, host wrapping doesn't apply - // but we'd still need to insert a label - _dynamic = false; +export class ClrRadioWrapper implements OnInit { @ContentChild(ClrLabel, { static: true }) label: ClrLabel; ngOnInit() { diff --git a/projects/angular/src/utils/host-wrapping/dynamic-wrapper.ts b/projects/angular/src/utils/host-wrapping/dynamic-wrapper.ts deleted file mode 100644 index 2bc31f14df..0000000000 --- a/projects/angular/src/utils/host-wrapping/dynamic-wrapper.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) 2016-2024 Broadcom. All Rights Reserved. - * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. - * This software is released under MIT license. - * The full license information can be found in LICENSE in the root directory of this project. - */ - -export interface DynamicWrapper { - _dynamic: boolean; -} diff --git a/projects/angular/src/utils/host-wrapping/host-wrapper.ts b/projects/angular/src/utils/host-wrapping/host-wrapper.ts index 6338b730b6..dd0827e69e 100644 --- a/projects/angular/src/utils/host-wrapping/host-wrapper.ts +++ b/projects/angular/src/utils/host-wrapping/host-wrapper.ts @@ -15,7 +15,6 @@ import { ViewContainerRef, } from '@angular/core'; -import { DynamicWrapper } from './dynamic-wrapper'; import { EmptyAnchor } from './empty-anchor'; /** @@ -23,7 +22,7 @@ import { EmptyAnchor } from './empty-anchor'; * still undefined. * TODO - make sure these comment annotations do not break ng-packgr. */ -export class HostWrapper implements Injector { +export class HostWrapper implements Injector { private injector: Injector; constructor(containerType: Type, vcr: ViewContainerRef, index = 0) { @@ -47,9 +46,6 @@ export class HostWrapper implements Injector { // We can now remove the useless anchor vcr.remove(0); - // We note that the container was dynamically created - containerRef.instance._dynamic = true; - // We keep the wrapper's injector to access the dependencies that weren't available before. this.injector = containerRef.injector; } diff --git a/projects/angular/src/utils/host-wrapping/host-wrapping.spec.ts b/projects/angular/src/utils/host-wrapping/host-wrapping.spec.ts index 98bf410aca..9e0d30d7bc 100644 --- a/projects/angular/src/utils/host-wrapping/host-wrapping.spec.ts +++ b/projects/angular/src/utils/host-wrapping/host-wrapping.spec.ts @@ -10,7 +10,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { DynamicWrapper } from './dynamic-wrapper'; import { HostWrapper } from './host-wrapper'; import { ClrHostWrappingModule } from './host-wrapping.module'; @@ -21,9 +20,7 @@ const WRAPPER_SERVICE = new InjectionToken('WrapperService'); template: `Hello !`, providers: [{ provide: WRAPPER_SERVICE, useValue: 42 }], }) -class WrapperComponent implements DynamicWrapper { - _dynamic = false; -} +class WrapperComponent {} @Directive({ selector: '[wrappedDirective]', @@ -94,10 +91,6 @@ describe('Host wrapping', function () { expect(this.fixture.nativeElement.textContent.trim()).toBe('Hello World!'); }); - it("doesn't mark the wrapper as dynamically created", function (this: TestContext) { - expect(this.wrapper._dynamic).toBe(false); - }); - it('proxies to the default injector', function (this: TestContext) { expect(this.wrapped.injected).toBe(42); }); @@ -121,10 +114,6 @@ describe('Host wrapping', function () { expect(this.fixture.nativeElement.textContent.trim()).toBe('Hello World!'); }); - it('marks the wrapper as dynamically created', function (this: TestContext) { - expect(this.wrapper._dynamic).toBe(true); - }); - it("proxies to the newly created wrapper's injector", function (this: TestContext) { expect(this.wrapped.injected).toBe(42); });