diff --git a/aio/tools/examples/run-example-e2e.js b/aio/tools/examples/run-example-e2e.js index 25e9f038043ce..27bba29d50123 100644 --- a/aio/tools/examples/run-example-e2e.js +++ b/aio/tools/examples/run-example-e2e.js @@ -21,8 +21,6 @@ const IGNORED_EXAMPLES = [ ]; const fixmeIvyExamples = [ - // fixmeIvy('FW-1069: ngtsc does not support inline ', + }) + 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 tags', () => { + env.tsconfig(); + env.write('style.css', `h1 {font-size: larger}`); + env.write('test.ts', ` + import {Component} from '@angular/core'; + + @Component({ + selector: 'test', + template: '', + }) + export class TestCmp {} + `); + + env.driveMain(); + const jsContents = env.getContents('test.js'); + expect(jsContents).toContain('styles: ["h1[_ngcontent-%COMP%] {font-size: larger}"]'); + }); + }); }); function expectTokenAtPosition( diff --git a/packages/compiler/src/render3/r3_template_transform.ts b/packages/compiler/src/render3/r3_template_transform.ts index c8fd92d270783..371dda13b411c 100644 --- a/packages/compiler/src/render3/r3_template_transform.ts +++ b/packages/compiler/src/render3/r3_template_transform.ts @@ -47,9 +47,12 @@ const IDENT_EVENT_IDX = 10; const TEMPLATE_ATTR_PREFIX = '*'; // Result of the html AST to Ivy AST transformation -export type Render3ParseResult = { - nodes: t.Node[]; errors: ParseError[]; -}; +export interface Render3ParseResult { + nodes: t.Node[]; + errors: ParseError[]; + styles: string[]; + styleUrls: string[]; +} export function htmlAstToRender3Ast( htmlNodes: html.Node[], bindingParser: BindingParser): Render3ParseResult { @@ -68,28 +71,33 @@ export function htmlAstToRender3Ast( return { nodes: ivyNodes, errors: allErrors, + styleUrls: transformer.styleUrls, + styles: transformer.styles, }; } class HtmlAstToIvyAst implements html.Visitor { errors: ParseError[] = []; + styles: string[] = []; + styleUrls: string[] = []; constructor(private bindingParser: BindingParser) {} // HTML visitor visitElement(element: html.Element): t.Node|null { const preparsedElement = preparseElement(element); - if (preparsedElement.type === PreparsedElementType.SCRIPT || - preparsedElement.type === PreparsedElementType.STYLE) { - // Skipping