perf(core): add option to remove blank text nodes from compiled templates (#18823)
PR Close #18823
This commit is contained in:

committed by
Miško Hevery

parent
7ec28fe9af
commit
b8b551cf2b
@ -1772,6 +1772,51 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
});
|
||||
|
||||
describe('whitespaces in templates', () => {
|
||||
it('should not remove whitespaces by default', async(() => {
|
||||
@Component({
|
||||
selector: 'comp',
|
||||
template: '<span>foo</span> <span>bar</span>',
|
||||
})
|
||||
class MyCmp {
|
||||
}
|
||||
|
||||
const f = TestBed.configureTestingModule({declarations: [MyCmp]}).createComponent(MyCmp);
|
||||
f.detectChanges();
|
||||
|
||||
expect(f.nativeElement.childNodes.length).toBe(3);
|
||||
}));
|
||||
|
||||
it('should not remove whitespaces when explicitly requested not to do so', async(() => {
|
||||
@Component({
|
||||
selector: 'comp',
|
||||
template: '<span>foo</span> <span>bar</span>',
|
||||
preserveWhitespaces: true,
|
||||
})
|
||||
class MyCmp {
|
||||
}
|
||||
|
||||
const f = TestBed.configureTestingModule({declarations: [MyCmp]}).createComponent(MyCmp);
|
||||
f.detectChanges();
|
||||
|
||||
expect(f.nativeElement.childNodes.length).toBe(3);
|
||||
}));
|
||||
|
||||
it('should remove whitespaces when explicitly requested to do so', async(() => {
|
||||
@Component({
|
||||
selector: 'comp',
|
||||
template: '<span>foo</span> <span>bar</span>',
|
||||
preserveWhitespaces: false,
|
||||
})
|
||||
class MyCmp {
|
||||
}
|
||||
|
||||
const f = TestBed.configureTestingModule({declarations: [MyCmp]}).createComponent(MyCmp);
|
||||
f.detectChanges();
|
||||
|
||||
expect(f.nativeElement.childNodes.length).toBe(2);
|
||||
}));
|
||||
});
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
describe('svg', () => {
|
||||
|
Reference in New Issue
Block a user