Skip to content

Commit b486e4d

Browse files
committed
fixup! refactor(compiler): emit instructions for foreign components
1 parent b26fc24 commit b486e4d

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/standalone/foreign_component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class TestCmp {
77
vars: 0,
88
template: function TestCmp_Template(rf, ctx) {
99
if (rf & 1) {
10-
i0.ɵɵforeignComponent(0, frameworkImport(FancyButton), { class: "btn-cls", label: ctx.title });
10+
i0.ɵɵforeignComponent(0, frameworkImport(FancyButton), { class: "btn-cls", "unsafe-attr": "value", label: ctx.title, "unsafe-input": ctx.title });
1111
}
1212
},
1313
encapsulation: 2

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/standalone/foreign_component.local.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class TestCmp {
77
vars: 0,
88
template: function TestCmp_Template(rf, ctx) {
99
if (rf & 1) {
10-
i0.ɵɵforeignComponent(0, frameworkImport(FancyButton), { class: "btn-cls", label: ctx.title });
10+
i0.ɵɵforeignComponent(0, frameworkImport(FancyButton), { class: "btn-cls", "unsafe-attr": "value", label: ctx.title, "unsafe-input": ctx.title });
1111
}
1212
},
1313
encapsulation: 2

packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/standalone/foreign_component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ function frameworkImport(component: {}): Function {
99

1010
@Component({
1111
selector: 'main',
12-
template: '<FancyButton class="btn-cls" [label]="title"></FancyButton>',
12+
template: `
13+
<FancyButton
14+
class="btn-cls"
15+
unsafe-attr="value"
16+
[label]="title"
17+
[unsafe-input]="title"
18+
/>
19+
`,
1320
// @ts-ignore: @angular/core does not expose the `foreignImports` property.
1421
foreignImports: [
1522
// @ts-ignore: @angular/core does not expose the `ForeignComponent` type this expects.

packages/compiler/src/template/pipeline/src/ingest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {splitNsName} from '../../../ml_parser/tags';
1414
import * as o from '../../../output/output_ast';
1515
import {ParseSourceSpan} from '../../../parse_util';
1616
import * as t from '../../../render3/r3_ast';
17+
import {isUnsafeObjectKey} from '../../../render3/util';
1718
import {
1819
DeferBlockDepsEmitMode,
1920
R3ComponentDeferMetadata,
@@ -296,14 +297,14 @@ function ingestElement(unit: ViewCompilationUnit, element: t.Element): void {
296297
propEntries.push({
297298
key: attr.name,
298299
value: o.literal(attr.value),
299-
quoted: false,
300+
quoted: isUnsafeObjectKey(attr.name),
300301
});
301302
}
302303
for (const input of element.inputs) {
303304
propEntries.push({
304305
key: input.name,
305306
value: convertAst(input.value, unit.job, input.sourceSpan),
306-
quoted: false,
307+
quoted: isUnsafeObjectKey(input.name),
307308
});
308309
}
309310
const props = propEntries.length > 0 ? o.literalMap(propEntries) : null;

0 commit comments

Comments
 (0)