fix(ivy): take styles extracted from template into account in JIT mode (#34017)
Prior to this commit, all styles extracted from Component's template (defined using <style> tags) were ignored by JIT compiler, so only `styles` array values defined in @Component decorator were used. This change updates JIT compiler to take styles extracted from the template into account. It also ensures correct order where `styles` array values are applied first and template styles are applied second. PR Close #34017
This commit is contained in:

committed by
Matias Niemelä

parent
1d513e8978
commit
b659aa32c9
@ -2410,6 +2410,33 @@ describe('styling', () => {
|
||||
.toEqual('url("https://i.imgur.com/4AiXzf8.jpg")');
|
||||
});
|
||||
});
|
||||
|
||||
isBrowser && it('should process <style> tag contents extracted from template', () => {
|
||||
@Component({
|
||||
template: `
|
||||
<style>
|
||||
div { width: 10px; }
|
||||
</style>
|
||||
<div></div>
|
||||
`,
|
||||
styles: [
|
||||
'div { width: 100px; }',
|
||||
]
|
||||
})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp],
|
||||
});
|
||||
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
// `styles` array values are applied first, styles from <style> tags second.
|
||||
const div = fixture.nativeElement.querySelector('div');
|
||||
expect(getComputedStyle(div).width).toBe('10px');
|
||||
});
|
||||
});
|
||||
|
||||
function assertStyleCounters(countForSet: number, countForRemove: number) {
|
||||
|
Reference in New Issue
Block a user