fix(ivy): wrap "inputs" and "outputs" keys if they contain unsafe characters (#28919)
Prior to this change, keys in "inputs" and "outputs" objects generated by compiler were not checked against unsafe characters. As a result, in some cases the generated code was throwing JS error. Now we check whether a given key contains any unsafe chars and wrap it in quotes if needed. PR Close #28919
This commit is contained in:
@ -2148,6 +2148,28 @@ describe('ngtsc behavioral tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap "inputs" and "outputs" keys if they contain unsafe characters', () => {
|
||||
env.tsconfig({});
|
||||
env.write(`test.ts`, `
|
||||
import {Directive} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[somedir]',
|
||||
inputs: ['input-track-type', 'inputTrackName'],
|
||||
outputs: ['output-track-type', 'outputTrackName']
|
||||
})
|
||||
export class SomeDir {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
const inputsAndOutputs = `
|
||||
inputs: { "input-track-type": "input-track-type", inputTrackName: "inputTrackName" },
|
||||
outputs: { "output-track-type": "output-track-type", outputTrackName: "outputTrackName" }
|
||||
`;
|
||||
expect(trim(jsContents)).toContain(trim(inputsAndOutputs));
|
||||
});
|
||||
|
||||
it('should compile programs with typeRoots', () => {
|
||||
// Write out a custom tsconfig.json that includes 'typeRoots' and 'files'. 'files' is necessary
|
||||
// because otherwise TS picks up the testTypeRoot/test/index.d.ts file into the program
|
||||
|
Reference in New Issue
Block a user