fix(ivy): i18n should not alloc expando slots when there is no new var (#31451)
`i18nStart` was calling `allocExpando` even if there was 0 new variable created. This created a new expando instruction with the value 0 which was later interpreted as the start of a new expando block instead of just skipping 0 instructions. FW-1417 #resolve PR Close #31451
This commit is contained in:

committed by
Jason Aden

parent
989ebcbb62
commit
2b44be984e
@ -1463,6 +1463,30 @@ onlyInIvy('Ivy i18n logic').describe('runtime i18n', () => {
|
||||
.toEqual(`<div-query>Contenu<!--ng-container--></div-query>`);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not alloc expando slots when there is no new variable to create', () => {
|
||||
@Component({
|
||||
template: `
|
||||
<div dialog i18n>
|
||||
<div *ngIf="data">
|
||||
Some content
|
||||
</div>
|
||||
</div>
|
||||
<button [close]="true">Button label</button>
|
||||
`
|
||||
})
|
||||
class ContentElementDialog {
|
||||
data = false;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [DialogDir, CloseBtn, ContentElementDialog]});
|
||||
|
||||
const fixture = TestBed.createComponent(ContentElementDialog);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div dialog=""><!--bindings={
|
||||
"ng-reflect-ng-if": "false"
|
||||
}--></div><button ng-reflect-dialog-result="true" title="Close dialog">Button label</button>`);
|
||||
});
|
||||
});
|
||||
|
||||
function initWithTemplate(compType: Type<any>, template: string) {
|
||||
@ -1491,3 +1515,13 @@ class DirectiveWithTplRef {
|
||||
class UppercasePipe implements PipeTransform {
|
||||
transform(value: string) { return value.toUpperCase(); }
|
||||
}
|
||||
|
||||
@Directive({selector: `[dialog]`})
|
||||
export class DialogDir {
|
||||
}
|
||||
|
||||
@Directive({selector: `button[close]`, host: {'[title]': 'name'}})
|
||||
export class CloseBtn {
|
||||
@Input('close') dialogResult: any;
|
||||
name: string = 'Close dialog';
|
||||
}
|
||||
|
Reference in New Issue
Block a user