fix(Renderer): update signatures to make RenderDebugInfo optional

The code does not force the user to provider `RenderDebugInfo`. The
current implementation lists this as a mandatory parameter. Update
the parameter to be optional.

Fixes #8466

Closes #8859
This commit is contained in:
Matt Wheatley 2016-05-26 14:41:33 +01:00 committed by Misko Hevery
parent 3a62023260
commit b7b56785d1
3 changed files with 15 additions and 15 deletions

View File

@ -24,14 +24,14 @@ export class DebugDomRootRenderer implements RootRenderer {
export class DebugDomRenderer implements Renderer { export class DebugDomRenderer implements Renderer {
constructor(private _delegate: Renderer) {} constructor(private _delegate: Renderer) {}
selectRootElement(selectorOrNode: string | any, debugInfo: RenderDebugInfo): any { selectRootElement(selectorOrNode: string | any, debugInfo?: RenderDebugInfo): any {
var nativeEl = this._delegate.selectRootElement(selectorOrNode, debugInfo); var nativeEl = this._delegate.selectRootElement(selectorOrNode, debugInfo);
var debugEl = new DebugElement(nativeEl, null, debugInfo); var debugEl = new DebugElement(nativeEl, null, debugInfo);
indexDebugNode(debugEl); indexDebugNode(debugEl);
return nativeEl; return nativeEl;
} }
createElement(parentElement: any, name: string, debugInfo: RenderDebugInfo): any { createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any {
var nativeEl = this._delegate.createElement(parentElement, name, debugInfo); var nativeEl = this._delegate.createElement(parentElement, name, debugInfo);
var debugEl = new DebugElement(nativeEl, getDebugNode(parentElement), debugInfo); var debugEl = new DebugElement(nativeEl, getDebugNode(parentElement), debugInfo);
debugEl.name = name; debugEl.name = name;
@ -41,14 +41,14 @@ export class DebugDomRenderer implements Renderer {
createViewRoot(hostElement: any): any { return this._delegate.createViewRoot(hostElement); } createViewRoot(hostElement: any): any { return this._delegate.createViewRoot(hostElement); }
createTemplateAnchor(parentElement: any, debugInfo: RenderDebugInfo): any { createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any {
var comment = this._delegate.createTemplateAnchor(parentElement, debugInfo); var comment = this._delegate.createTemplateAnchor(parentElement, debugInfo);
var debugEl = new DebugNode(comment, getDebugNode(parentElement), debugInfo); var debugEl = new DebugNode(comment, getDebugNode(parentElement), debugInfo);
indexDebugNode(debugEl); indexDebugNode(debugEl);
return comment; return comment;
} }
createText(parentElement: any, value: string, debugInfo: RenderDebugInfo): any { createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any {
var text = this._delegate.createText(parentElement, value, debugInfo); var text = this._delegate.createText(parentElement, value, debugInfo);
var debugEl = new DebugNode(text, getDebugNode(parentElement), debugInfo); var debugEl = new DebugNode(text, getDebugNode(parentElement), debugInfo);
indexDebugNode(debugEl); indexDebugNode(debugEl);
@ -136,7 +136,7 @@ export class DebugDomRenderer implements Renderer {
this._delegate.setElementStyle(renderElement, styleName, styleValue); this._delegate.setElementStyle(renderElement, styleName, styleValue);
} }
invokeElementMethod(renderElement: any, methodName: string, args: any[]) { invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {
this._delegate.invokeElementMethod(renderElement, methodName, args); this._delegate.invokeElementMethod(renderElement, methodName, args);
} }

View File

@ -26,15 +26,15 @@ export abstract class RenderDebugInfo {
* @experimental * @experimental
*/ */
export abstract class Renderer { export abstract class Renderer {
abstract selectRootElement(selectorOrNode: string | any, debugInfo: RenderDebugInfo): any; abstract selectRootElement(selectorOrNode: string | any, debugInfo?: RenderDebugInfo): any;
abstract createElement(parentElement: any, name: string, debugInfo: RenderDebugInfo): any; abstract createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any;
abstract createViewRoot(hostElement: any): any; abstract createViewRoot(hostElement: any): any;
abstract createTemplateAnchor(parentElement: any, debugInfo: RenderDebugInfo): any; abstract createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any;
abstract createText(parentElement: any, value: string, debugInfo: RenderDebugInfo): any; abstract createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any;
abstract projectNodes(parentElement: any, nodes: any[]): void; abstract projectNodes(parentElement: any, nodes: any[]): void;
@ -65,7 +65,7 @@ export abstract class Renderer {
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[]);
abstract setText(renderNode: any, text: string); abstract setText(renderNode: any, text: string);

View File

@ -92,14 +92,14 @@ export class WebWorkerRenderer implements Renderer, RenderStoreObject {
this._rootRenderer.runOnService(fnName, fnArgsWithRenderer); this._rootRenderer.runOnService(fnName, fnArgsWithRenderer);
} }
selectRootElement(selectorOrNode: string, debugInfo: RenderDebugInfo): any { selectRootElement(selectorOrNode: string, debugInfo?: RenderDebugInfo): any {
var node = this._rootRenderer.allocateNode(); var node = this._rootRenderer.allocateNode();
this._runOnService('selectRootElement', this._runOnService('selectRootElement',
[new FnArg(selectorOrNode, null), new FnArg(node, RenderStoreObject)]); [new FnArg(selectorOrNode, null), new FnArg(node, RenderStoreObject)]);
return node; return node;
} }
createElement(parentElement: any, name: string, debugInfo: RenderDebugInfo): any { createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any {
var node = this._rootRenderer.allocateNode(); var node = this._rootRenderer.allocateNode();
this._runOnService('createElement', [ this._runOnService('createElement', [
new FnArg(parentElement, RenderStoreObject), new FnArg(parentElement, RenderStoreObject),
@ -119,7 +119,7 @@ export class WebWorkerRenderer implements Renderer, RenderStoreObject {
return viewRoot; return viewRoot;
} }
createTemplateAnchor(parentElement: any, debugInfo: RenderDebugInfo): any { createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any {
var node = this._rootRenderer.allocateNode(); var node = this._rootRenderer.allocateNode();
this._runOnService( this._runOnService(
'createTemplateAnchor', 'createTemplateAnchor',
@ -127,7 +127,7 @@ export class WebWorkerRenderer implements Renderer, RenderStoreObject {
return node; return node;
} }
createText(parentElement: any, value: string, debugInfo: RenderDebugInfo): any { createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any {
var node = this._rootRenderer.allocateNode(); var node = this._rootRenderer.allocateNode();
this._runOnService('createText', [ this._runOnService('createText', [
new FnArg(parentElement, RenderStoreObject), new FnArg(parentElement, RenderStoreObject),
@ -205,7 +205,7 @@ export class WebWorkerRenderer implements Renderer, RenderStoreObject {
]); ]);
} }
invokeElementMethod(renderElement: any, methodName: string, args: any[]) { invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {
this._runOnService('invokeElementMethod', [ this._runOnService('invokeElementMethod', [
new FnArg(renderElement, RenderStoreObject), new FnArg(renderElement, RenderStoreObject),
new FnArg(methodName, null), new FnArg(methodName, null),