fix(ivy): error if directive with synthetic property binding is on same node as directive that injects ViewContainerRef (#35343)

In the `loadRenderer` we make an assumption that the value will always be an `LView`, but if there's a directive on the same node which injects `ViewContainerRef` the `LView` will be wrapped in an `LContainer`. These changes add a call to unwrap the value before we try to read the value off of it.

Fixes #35342.

PR Close #35343
This commit is contained in:
crisbeto
2020-02-11 19:56:46 +01:00
committed by Kara Erickson
parent e8ea3be843
commit d6bc63fa38
2 changed files with 32 additions and 3 deletions

View File

@ -5,8 +5,9 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {state, style, trigger} from '@angular/animations';
import {CommonModule} from '@angular/common';
import {Component, Directive, EventEmitter, Input, Output} from '@angular/core';
import {Component, Directive, EventEmitter, Input, Output, ViewContainerRef} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {By, DomSanitizer, SafeUrl} from '@angular/platform-browser';
@ -598,4 +599,32 @@ describe('property bindings', () => {
});
it('should not throw on synthetic property bindings when a directive on the same element injects ViewContainerRef',
() => {
@Component({
selector: 'my-comp',
template: '',
animations: [trigger('trigger', [state('void', style({opacity: 0}))])],
host: {'[@trigger]': '"void"'}
})
class MyComp {
}
@Directive({selector: '[my-dir]'})
class MyDir {
constructor(public viewContainerRef: ViewContainerRef) {}
}
@Component({template: '<my-comp my-dir></my-comp>'})
class App {
}
TestBed.configureTestingModule({declarations: [App, MyDir, MyComp]});
expect(() => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
}).not.toThrow();
});
});