feat(ivy): support inline <style> and <link> tags in components (#28997)
Angular supports using <style> and <link> tags inline in component templates, but previously such tags were not implemented within the ngtsc compiler. This commit introduces that support. FW-1069 #resolve PR Close #28997
This commit is contained in:

committed by
Ben Lesh

parent
40833ba54b
commit
827e89cfc4
@ -3315,6 +3315,43 @@ export const Foo = Foo__PRE_R3__;
|
||||
expect(jsContents).toContain('export { FooDir as ɵng$root$foo$$FooDir } from "root/foo";');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inline resources', () => {
|
||||
it('should process inline <style> tags', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: '<style>h1 {font-size: larger}</style>',
|
||||
})
|
||||
export class TestCmp {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('styles: ["h1[_ngcontent-%COMP%] {font-size: larger}"]');
|
||||
});
|
||||
|
||||
it('should process inline <link> tags', () => {
|
||||
env.tsconfig();
|
||||
env.write('style.css', `h1 {font-size: larger}`);
|
||||
env.write('test.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: '<link rel="stylesheet" href="./style.css">',
|
||||
})
|
||||
export class TestCmp {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('styles: ["h1[_ngcontent-%COMP%] {font-size: larger}"]');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function expectTokenAtPosition<T extends ts.Node>(
|
||||
|
Reference in New Issue
Block a user