fix(renderer): remove unecessary setElementStyles method
There is no need to expose this additional method inside of the Renderer API. The functionality can be restored by looping and calling `setElementStyle` instead. Note that this change is changing code that was was introduced after the last release therefore this fix is not a breaking change. Closes #9000 Closes #9009
This commit is contained in:
parent
a6ad61d83e
commit
e504d4eb05
|
@ -84,3 +84,4 @@ export var balanceAnimationKeyframes: typeof t.balanceAnimationKeyframes = r.bal
|
||||||
export var flattenStyles: typeof t.flattenStyles = r.flattenStyles;
|
export var flattenStyles: typeof t.flattenStyles = r.flattenStyles;
|
||||||
export var clearStyles: typeof t.clearStyles = r.clearStyles;
|
export var clearStyles: typeof t.clearStyles = r.clearStyles;
|
||||||
export var collectAndResolveStyles: typeof r.collectAndResolveStyles = r.collectAndResolveStyles;
|
export var collectAndResolveStyles: typeof r.collectAndResolveStyles = r.collectAndResolveStyles;
|
||||||
|
export var renderStyles: typeof t.renderStyles = r.renderStyles;
|
||||||
|
|
|
@ -243,12 +243,16 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
||||||
_ANIMATION_END_STATE_STYLES_VAR.set(EMPTY_MAP).toStmt()
|
_ANIMATION_END_STATE_STYLES_VAR.set(EMPTY_MAP).toStmt()
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
|
||||||
|
var RENDER_STYLES_FN = o.importExpr(Identifiers.renderStyles);
|
||||||
|
|
||||||
// before we start any animation we want to clear out the starting
|
// before we start any animation we want to clear out the starting
|
||||||
// styles from the element's style property (since they were placed
|
// styles from the element's style property (since they were placed
|
||||||
// there at the end of the last animation
|
// there at the end of the last animation
|
||||||
statements.push(
|
statements.push(
|
||||||
_ANIMATION_FACTORY_RENDERER_VAR.callMethod('setElementStyles', [
|
RENDER_STYLES_FN.callFn([
|
||||||
_ANIMATION_FACTORY_ELEMENT_VAR,
|
_ANIMATION_FACTORY_ELEMENT_VAR,
|
||||||
|
_ANIMATION_FACTORY_RENDERER_VAR,
|
||||||
o.importExpr(Identifiers.clearStyles).callFn([_ANIMATION_START_STATE_STYLES_VAR])
|
o.importExpr(Identifiers.clearStyles).callFn([_ANIMATION_START_STATE_STYLES_VAR])
|
||||||
]).toStmt());
|
]).toStmt());
|
||||||
|
|
||||||
|
@ -269,8 +273,9 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
||||||
statements.push(
|
statements.push(
|
||||||
_ANIMATION_PLAYER_VAR.callMethod('onDone', [
|
_ANIMATION_PLAYER_VAR.callMethod('onDone', [
|
||||||
o.fn([], [
|
o.fn([], [
|
||||||
_ANIMATION_FACTORY_RENDERER_VAR.callMethod('setElementStyles', [
|
RENDER_STYLES_FN.callFn([
|
||||||
_ANIMATION_FACTORY_ELEMENT_VAR,
|
_ANIMATION_FACTORY_ELEMENT_VAR,
|
||||||
|
_ANIMATION_FACTORY_RENDERER_VAR,
|
||||||
o.importExpr(Identifiers.balanceAnimationStyles).callFn([
|
o.importExpr(Identifiers.balanceAnimationStyles).callFn([
|
||||||
_ANIMATION_START_STATE_STYLES_VAR,
|
_ANIMATION_START_STATE_STYLES_VAR,
|
||||||
_ANIMATION_END_STATE_STYLES_VAR
|
_ANIMATION_END_STATE_STYLES_VAR
|
||||||
|
|
|
@ -49,6 +49,7 @@ import {
|
||||||
balanceAnimationKeyframes as impBalanceAnimationKeyframes,
|
balanceAnimationKeyframes as impBalanceAnimationKeyframes,
|
||||||
clearStyles as impClearStyles,
|
clearStyles as impClearStyles,
|
||||||
collectAndResolveStyles as impCollectAndResolveStyles,
|
collectAndResolveStyles as impCollectAndResolveStyles,
|
||||||
|
renderStyles as impRenderStyles,
|
||||||
SecurityContext
|
SecurityContext
|
||||||
} from '../core_private';
|
} from '../core_private';
|
||||||
|
|
||||||
|
@ -260,6 +261,11 @@ export class Identifiers {
|
||||||
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
runtime: impClearStyles
|
runtime: impClearStyles
|
||||||
});
|
});
|
||||||
|
static renderStyles = new CompileIdentifierMetadata({
|
||||||
|
name: 'renderStyles',
|
||||||
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
|
runtime: impRenderStyles
|
||||||
|
});
|
||||||
static collectAndResolveStyles = new CompileIdentifierMetadata({
|
static collectAndResolveStyles = new CompileIdentifierMetadata({
|
||||||
name: 'collectAndResolveStyles',
|
name: 'collectAndResolveStyles',
|
||||||
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
|
|
|
@ -125,6 +125,7 @@ export declare namespace __core_private_types__ {
|
||||||
export var balanceAnimationKeyframes: typeof animationUtils.balanceAnimationKeyframes;
|
export var balanceAnimationKeyframes: typeof animationUtils.balanceAnimationKeyframes;
|
||||||
export var flattenStyles: typeof animationUtils.flattenStyles;
|
export var flattenStyles: typeof animationUtils.flattenStyles;
|
||||||
export var clearStyles: typeof animationUtils.clearStyles;
|
export var clearStyles: typeof animationUtils.clearStyles;
|
||||||
|
export var renderStyles: typeof animationUtils.renderStyles;
|
||||||
export var collectAndResolveStyles: typeof animationUtils.collectAndResolveStyles;
|
export var collectAndResolveStyles: typeof animationUtils.collectAndResolveStyles;
|
||||||
export type AnimationStyles = AnimationStyles_;
|
export type AnimationStyles = AnimationStyles_;
|
||||||
export var AnimationStyles: typeof AnimationStyles_;
|
export var AnimationStyles: typeof AnimationStyles_;
|
||||||
|
@ -194,6 +195,7 @@ export var __core_private__ = {
|
||||||
balanceAnimationKeyframes: animationUtils.balanceAnimationKeyframes,
|
balanceAnimationKeyframes: animationUtils.balanceAnimationKeyframes,
|
||||||
flattenStyles: animationUtils.flattenStyles,
|
flattenStyles: animationUtils.flattenStyles,
|
||||||
clearStyles: animationUtils.clearStyles,
|
clearStyles: animationUtils.clearStyles,
|
||||||
|
renderStyles: animationUtils.renderStyles,
|
||||||
collectAndResolveStyles: animationUtils.collectAndResolveStyles,
|
collectAndResolveStyles: animationUtils.collectAndResolveStyles,
|
||||||
AnimationStyles: AnimationStyles_,
|
AnimationStyles: AnimationStyles_,
|
||||||
ANY_STATE: ANY_STATE_,
|
ANY_STATE: ANY_STATE_,
|
||||||
|
|
|
@ -101,6 +101,12 @@ export function collectAndResolveStyles(collection: {[key: string]: string|numbe
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderStyles(element: any, renderer: any, styles: {[key: string]: string|number}): void {
|
||||||
|
StringMapWrapper.forEach(styles, (value, prop) => {
|
||||||
|
renderer.setElementStyle(element, prop, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function flattenStyles(styles: {[key: string]: string|number}[]) {
|
export function flattenStyles(styles: {[key: string]: string|number}[]) {
|
||||||
var finalStyles = {};
|
var finalStyles = {};
|
||||||
styles.forEach(entry => {
|
styles.forEach(entry => {
|
||||||
|
|
|
@ -134,17 +134,6 @@ export class DebugDomRenderer implements Renderer {
|
||||||
this._delegate.setElementClass(renderElement, className, isAdd);
|
this._delegate.setElementClass(renderElement, className, isAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
setElementStyles(renderElement: any, styles: {[key: string]: string}) {
|
|
||||||
var debugEl = getDebugNode(renderElement);
|
|
||||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
|
||||||
var elStyles = debugEl.styles;
|
|
||||||
StringMapWrapper.forEach(styles, (value, prop) => {
|
|
||||||
elStyles[prop] = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this._delegate.setElementStyles(renderElement, styles);
|
|
||||||
}
|
|
||||||
|
|
||||||
setElementStyle(renderElement: any, styleName: string, styleValue: string) {
|
setElementStyle(renderElement: any, styleName: string, styleValue: string) {
|
||||||
var debugEl = getDebugNode(renderElement);
|
var debugEl = getDebugNode(renderElement);
|
||||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
||||||
|
|
|
@ -61,8 +61,6 @@ export abstract class Renderer {
|
||||||
|
|
||||||
abstract setElementClass(renderElement: any, className: string, isAdd: boolean);
|
abstract setElementClass(renderElement: any, className: string, isAdd: boolean);
|
||||||
|
|
||||||
abstract setElementStyles(renderElement: any, styles: {[key: string]: string});
|
|
||||||
|
|
||||||
abstract setElementStyle(renderElement: any, styleName: string, styleValue: string);
|
abstract setElementStyle(renderElement: any, styleName: string, styleValue: string);
|
||||||
|
|
||||||
abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]);
|
abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]);
|
||||||
|
|
|
@ -228,11 +228,6 @@ export class DomRenderer implements Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setElementStyles(renderElement: any, styles: {[key: string]: string}) {
|
|
||||||
StringMapWrapper.forEach(styles,
|
|
||||||
(value, prop) => this.setElementStyle(renderElement, prop, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
setElementStyle(renderElement: any, styleName: string, styleValue: string): void {
|
setElementStyle(renderElement: any, styleName: string, styleValue: string): void {
|
||||||
if (isPresent(styleValue)) {
|
if (isPresent(styleValue)) {
|
||||||
getDOM().setStyle(renderElement, styleName, stringify(styleValue));
|
getDOM().setStyle(renderElement, styleName, stringify(styleValue));
|
||||||
|
|
|
@ -59,9 +59,6 @@ export class MessageBasedRenderer {
|
||||||
broker.registerMethod("setElementStyle",
|
broker.registerMethod("setElementStyle",
|
||||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||||
FunctionWrapper.bind(this._setElementStyle, this));
|
FunctionWrapper.bind(this._setElementStyle, this));
|
||||||
broker.registerMethod("setElementStyles",
|
|
||||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE],
|
|
||||||
FunctionWrapper.bind(this._setElementStyles, this));
|
|
||||||
broker.registerMethod("invokeElementMethod",
|
broker.registerMethod("invokeElementMethod",
|
||||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||||
FunctionWrapper.bind(this._invokeElementMethod, this));
|
FunctionWrapper.bind(this._invokeElementMethod, this));
|
||||||
|
@ -147,11 +144,6 @@ export class MessageBasedRenderer {
|
||||||
renderer.setElementStyle(renderElement, styleName, styleValue);
|
renderer.setElementStyle(renderElement, styleName, styleValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setElementStyles(renderer: Renderer, renderElement: any,
|
|
||||||
styles: {[key: string]: string}) {
|
|
||||||
renderer.setElementStyles(renderElement, styles);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _invokeElementMethod(renderer: Renderer, renderElement: any, methodName: string,
|
private _invokeElementMethod(renderer: Renderer, renderElement: any, methodName: string,
|
||||||
args: any[]) {
|
args: any[]) {
|
||||||
renderer.invokeElementMethod(renderElement, methodName, args);
|
renderer.invokeElementMethod(renderElement, methodName, args);
|
||||||
|
|
|
@ -191,11 +191,6 @@ export class WebWorkerRenderer implements Renderer, RenderStoreObject {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setElementStyles(renderElement: any, styles: {[key: string]: string}) {
|
|
||||||
this._runOnService('setElementStyles',
|
|
||||||
[new FnArg(renderElement, RenderStoreObject), new FnArg(styles, null)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
setElementStyle(renderElement: any, styleName: string, styleValue: string) {
|
setElementStyle(renderElement: any, styleName: string, styleValue: string) {
|
||||||
this._runOnService('setElementStyle', [
|
this._runOnService('setElementStyle', [
|
||||||
new FnArg(renderElement, RenderStoreObject),
|
new FnArg(renderElement, RenderStoreObject),
|
||||||
|
|
|
@ -156,15 +156,6 @@ export function main() {
|
||||||
renderer.setElementStyle(workerEl, 'width', null);
|
renderer.setElementStyle(workerEl, 'width', null);
|
||||||
expect(getDOM().getStyle(el, 'width')).toEqual('');
|
expect(getDOM().getStyle(el, 'width')).toEqual('');
|
||||||
|
|
||||||
renderer.setElementStyles(workerEl, {'height': '999px', 'opacity': '0.5'})
|
|
||||||
expect(getDOM().getStyle(el, 'height'))
|
|
||||||
.toEqual('999px');
|
|
||||||
expect(getDOM().getStyle(el, 'opacity')).toEqual('0.5');
|
|
||||||
renderer.setElementStyles(workerEl, {'height': '999px', 'opacity': null});
|
|
||||||
expect(getDOM().getStyle(el, 'height'))
|
|
||||||
.toEqual('999px');
|
|
||||||
expect(getDOM().getStyle(el, 'opacity')).toEqual('');
|
|
||||||
|
|
||||||
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
|
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
|
||||||
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
|
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
|
||||||
};
|
};
|
||||||
|
|
|
@ -457,7 +457,6 @@ const CORE = [
|
||||||
'Renderer.setElementClass(renderElement:any, className:string, isAdd:boolean):any',
|
'Renderer.setElementClass(renderElement:any, className:string, isAdd:boolean):any',
|
||||||
'Renderer.setElementProperty(renderElement:any, propertyName:string, propertyValue:any):void',
|
'Renderer.setElementProperty(renderElement:any, propertyName:string, propertyValue:any):void',
|
||||||
'Renderer.setElementStyle(renderElement:any, styleName:string, styleValue:string):any',
|
'Renderer.setElementStyle(renderElement:any, styleName:string, styleValue:string):any',
|
||||||
'Renderer.setElementStyles(renderElement:any, styles:{[key:string]:string}):any',
|
|
||||||
'Renderer.setText(renderNode:any, text:string):any',
|
'Renderer.setText(renderNode:any, text:string):any',
|
||||||
'ResolvedReflectiveBinding',
|
'ResolvedReflectiveBinding',
|
||||||
'ResolvedReflectiveFactory',
|
'ResolvedReflectiveFactory',
|
||||||
|
|
Loading…
Reference in New Issue