Skip to content

Commit

Permalink
fixup! feat(ivy): properly apply style="", [style], [style.foo] and […
Browse files Browse the repository at this point in the history
…attr.style] bindings
  • Loading branch information
matsko authored and mhevery committed Jun 24, 2018
1 parent 4f4ad9e commit fdc0343
Show file tree
Hide file tree
Showing 7 changed files with 534 additions and 348 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/render3/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ export function elementClass<T>(index: number, value: T | NO_CHANGE): void {
* bindings. If a style binding changes its value to null then the initial styling
* values that are passed in here will be applied to the element (if matched).
*/
export function elementStyling<T>(index: number, styles?: string[]): void {
export function elementStyling<T>(index: number, styles?: string[] | null): void {
viewData[index + HEADER_OFFSET] = initializeStylingContext(styles);
if (styles && styles.length) {
elementStylingApply(index);
Expand Down Expand Up @@ -1327,6 +1327,7 @@ export function elementStylingApply<T>(index: number): void {
* (Note that this is not the element index, but rather an index value allocated
* specifically for element styling--the index must be the next index after the element
* index.)
* @param styleIndex Index of the style property on this element. (Monotonically increasing.)
* @param styleName Name of property. Because it is going to DOM this is not subject to
* renaming as part of minification.
* @param value New value to write (null to remove).
Expand All @@ -1335,11 +1336,12 @@ export function elementStylingApply<T>(index: number): void {
* sanitization.
*/
export function elementStyleProp<T>(
index: number, styleName: string, value: T | null, suffix?: string): void;
index: number, styleIndex: number, styleName: string, value: T | null, suffix?: string): void;
export function elementStyleProp<T>(
index: number, styleName: string, value: T | null, sanitizer?: SanitizerFn): void;
index: number, styleIndex: number, styleName: string, value: T | null,
sanitizer?: SanitizerFn): void;
export function elementStyleProp<T>(
index: number, styleName: string, value: T | null,
index: number, styleIndex: number, styleName: string, value: T | null,
suffixOrSanitizer?: string | SanitizerFn): void {
const stylingContext: StylingContext = viewData[index + HEADER_OFFSET] !;
let valueToAdd: string|null = null;
Expand All @@ -1350,7 +1352,7 @@ export function elementStyleProp<T>(
valueToAdd = valueToAdd + suffixOrSanitizer;
}
}
updateElementStyleProp(stylingContext, styleName, valueToAdd);
updateElementStyleProp(stylingContext, styleIndex, styleName, valueToAdd);
}

/**
Expand Down

0 comments on commit fdc0343

Please sign in to comment.