fix(ivy): ensure host bindings and host styling works on a root component (#28664)

Prior to this fix if a root component was instantiated it create host
bindings, but never render them once update mode ran unless one or more
slot-allocated bindings were issued. Since styling in Ivy does not make
use of LView slots, the host bindings function never ran on the root
component.

This fix ensures that the `hostBindings` function does run for a root
component and also renders the schedlued styling instructions when
executed.

Jira Issue: FW-1062

PR Close #28664
This commit is contained in:
Matias Niemelä
2019-02-12 12:04:44 -08:00
committed by Miško Hevery
parent b41da03f00
commit 627cecdfe2
13 changed files with 134 additions and 45 deletions

View File

@ -14,7 +14,7 @@ import {LContext} from '../interfaces/context';
import {AttributeMarker, TAttributes, TNode, TNodeFlags} from '../interfaces/node';
import {PlayState, Player, PlayerContext, PlayerIndex} from '../interfaces/player';
import {RElement} from '../interfaces/renderer';
import {InitialStylingValues, StylingContext, StylingFlags, StylingIndex} from '../interfaces/styling';
import {InitialStylingValues, InitialStylingValuesIndex, StylingContext, StylingFlags, StylingIndex} from '../interfaces/styling';
import {HEADER_OFFSET, HOST, LView, RootContext} from '../interfaces/view';
import {getTNode} from '../util';
@ -100,10 +100,14 @@ export function getStylingContext(index: number, viewData: LView): StylingContex
}
}
export function isStylingContext(value: any): value is StylingContext {
export function isStylingContext(value: any): boolean {
// Not an LView or an LContainer
return Array.isArray(value) && typeof value[StylingIndex.MasterFlagPosition] === 'number' &&
value.length !== LCONTAINER_LENGTH;
if (Array.isArray(value) && value.length >= StylingIndex.SingleStylesStartPosition) {
return typeof value[StylingIndex.MasterFlagPosition] === 'number' &&
value[StylingIndex.InitialClassValuesPosition]
[InitialStylingValuesIndex.DefaultNullValuePosition] === null;
}
return false;
}
export function isAnimationProp(name: string): boolean {