fix(compiler): ensure that placeholders have the correct sourceSpan (… · angular/angular@8ec7156

@@ -427,6 +427,95 @@ runInEachFileSystem((os) => {

427427

});

428428

});

429429430+

it('should correctly handle collapsed whitespace in interpolation placeholder source-mappings',

431+

() => {

432+

const mappings = compileAndMap(

433+

`<div i18n title=" pre-title {{title_value}} post-title" i18n-title> pre-body {{body_value}} post-body</div>`);

434+

expectMapping(mappings, {

435+

source: '<div i18n title=" pre-title {{title_value}} post-title" i18n-title> ',

436+

generated: 'i0.ɵɵelementStart(0, "div", 0)',

437+

sourceUrl: '../test.ts',

438+

});

439+

expectMapping(mappings, {

440+

source: '</div>',

441+

generated: 'i0.ɵɵelementEnd()',

442+

sourceUrl: '../test.ts',

443+

});

444+

expectMapping(mappings, {

445+

source: ' pre-body ',

446+

generated: '` pre-body ${',

447+

sourceUrl: '../test.ts',

448+

});

449+

expectMapping(mappings, {

450+

source: '{{body_value}}',

451+

generated: '"\\uFFFD0\\uFFFD"',

452+

sourceUrl: '../test.ts',

453+

});

454+

expectMapping(mappings, {

455+

source: ' post-body',

456+

generated: '}:INTERPOLATION: post-body`',

457+

sourceUrl: '../test.ts',

458+

});

459+

});

460+461+

it('should correctly handle collapsed whitespace in element placeholder source-mappings',

462+

() => {

463+

const mappings =

464+

compileAndMap(`<div i18n>\n pre-p\n <p>\n in-p\n </p>\n post-p\n</div>`);

465+

// $localize expressions

466+

expectMapping(mappings, {

467+

sourceUrl: '../test.ts',

468+

source: 'pre-p\n ',

469+

generated: '` pre-p ${',

470+

});

471+

expectMapping(mappings, {

472+

sourceUrl: '../test.ts',

473+

source: '<p>\n ',

474+

generated: '"\\uFFFD#2\\uFFFD"',

475+

});

476+

expectMapping(mappings, {

477+

sourceUrl: '../test.ts',

478+

source: 'in-p\n ',

479+

generated: '}:START_PARAGRAPH: in-p ${',

480+

});

481+

expectMapping(mappings, {

482+

sourceUrl: '../test.ts',

483+

source: '</p>\n ',

484+

generated: '"\\uFFFD/#2\\uFFFD"',

485+

});

486+

expectMapping(mappings, {

487+

sourceUrl: '../test.ts',

488+

source: 'post-p\n',

489+

generated: '}:CLOSE_PARAGRAPH: post-p\n`',

490+

});

491+

// ivy instructions

492+

expectMapping(mappings, {

493+

sourceUrl: '../test.ts',

494+

source: '<div i18n>\n ',

495+

generated: 'i0.ɵɵelementStart(0, "div")',

496+

});

497+

expectMapping(mappings, {

498+

sourceUrl: '../test.ts',

499+

source: '<div i18n>\n ',

500+

generated: 'i0.ɵɵi18nStart(1, 0)',

501+

});

502+

expectMapping(mappings, {

503+

sourceUrl: '../test.ts',

504+

source: '<p>\n in-p\n </p>',

505+

generated: 'i0.ɵɵelement(2, "p")',

506+

});

507+

expectMapping(mappings, {

508+

sourceUrl: '../test.ts',

509+

source: '</div>',

510+

generated: 'i0.ɵɵi18nEnd()',

511+

});

512+

expectMapping(mappings, {

513+

sourceUrl: '../test.ts',

514+

source: '</div>',

515+

generated: 'i0.ɵɵelementEnd()',

516+

});

517+

});

518+430519

it('should create tag (container) placeholder source-mappings', () => {

431520

const mappings = compileAndMap(`<div i18n>Hello, <b>World</b>!</div>`);

432521

expectMapping(mappings, {