fix(core): allow to use the Renderer
outside of views. (#14882)
Fixes #14872
This commit is contained in:

committed by
Chuck Jazdzewski

parent
6cd3326b55
commit
ba4b6f58d9
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, InjectionToken, Injector, Pipe, PipeTransform, Provider} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, InjectionToken, Injector, Pipe, PipeTransform, Provider, RendererV2} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
@ -209,6 +209,19 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MainComponent);
|
||||
expect(fixture.nativeElement).toHaveText('I was saved by my hero from a villian.');
|
||||
});
|
||||
|
||||
it('should allow to use the renderer outside of views', () => {
|
||||
@Component({template: ''})
|
||||
class MyComp {
|
||||
constructor(public renderer: RendererV2) {}
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const ctx = TestBed.createComponent(MyComp);
|
||||
|
||||
const txtNode = ctx.componentInstance.renderer.createText('test');
|
||||
expect(txtNode).toHaveText('test');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user