refactor(render): use RenderElementRef in all renderer methods

BREAKING CHANGES:
- Almost all methods in `Renderer` now take a `RenderElementRef` instead
  of a `ViewRef` + `boundElementIndex`.
- These methods can be called with the `ElementRef` from the app side
  directly.

Closes #2706
Related to #2476
This commit is contained in:
Tobias Bosch
2015-06-23 11:21:56 -07:00
parent 2c3c235969
commit ba9fecd068
13 changed files with 139 additions and 127 deletions
+14 -18
View File
@@ -306,6 +306,11 @@ export class RenderCompiler {
compile(template: ViewDefinition): Promise<ProtoViewDto> { return null; }
}
export interface RenderElementRef {
renderView: RenderViewRef;
boundElementIndex: number;
}
export class Renderer {
/**
* Creates a root host view that includes the given element.
@@ -333,29 +338,25 @@ export class Renderer {
/**
* Attaches a componentView into the given hostView at the given element
*/
attachComponentView(hostViewRef: RenderViewRef, elementIndex: number,
componentViewRef: RenderViewRef) {}
attachComponentView(location: RenderElementRef, componentViewRef: RenderViewRef) {}
/**
* Detaches a componentView into the given hostView at the given element
*/
detachComponentView(hostViewRef: RenderViewRef, boundElementIndex: number,
componentViewRef: RenderViewRef) {}
detachComponentView(location: RenderElementRef, componentViewRef: RenderViewRef) {}
/**
* Attaches a view into a ViewContainer (in the given parentView at the given element) at the
* given index.
*/
attachViewInContainer(parentViewRef: RenderViewRef, boundElementIndex: number, atIndex: number,
viewRef: RenderViewRef) {}
attachViewInContainer(location: RenderElementRef, atIndex: number, viewRef: RenderViewRef) {}
/**
* Detaches a view into a ViewContainer (in the given parentView at the given element) at the
* given index.
*/
// TODO(tbosch): this should return a promise as it can be animated!
detachViewInContainer(parentViewRef: RenderViewRef, boundElementIndex: number, atIndex: number,
viewRef: RenderViewRef) {}
detachViewInContainer(location: RenderElementRef, atIndex: number, viewRef: RenderViewRef) {}
/**
* Hydrates a view after it has been attached. Hydration/dehydration is used for reusing views
@@ -372,32 +373,27 @@ export class Renderer {
/**
* Sets a property on an element.
*/
setElementProperty(viewRef: RenderViewRef, elementIndex: number, propertyName: string,
propertyValue: any) {}
setElementProperty(location: RenderElementRef, propertyName: string, propertyValue: any) {}
/**
* Sets an attribute on an element.
*/
setElementAttribute(viewRef: RenderViewRef, elementIndex: number, attributeName: string,
attributeValue: string) {}
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string) {}
/**
* Sets a class on an element.
*/
setElementClass(viewRef: RenderViewRef, elementIndex: number, className: string, isAdd: boolean) {
}
setElementClass(location: RenderElementRef, className: string, isAdd: boolean) {}
/**
* Sets a style on an element.
*/
setElementStyle(viewRef: RenderViewRef, elementIndex: number, styleName: string,
styleValue: string) {}
setElementStyle(location: RenderElementRef, styleName: string, styleValue: string) {}
/**
* Calls a method on an element.
*/
invokeElementMethod(viewRef: RenderViewRef, elementIndex: number, methodName: string,
args: List<any>) {}
invokeElementMethod(location: RenderElementRef, methodName: string, args: List<any>) {}
/**
* Sets the value of a text node.