From ff15043e488743657fd0f83801de7c6f87c9337f Mon Sep 17 00:00:00 2001 From: Manduro Date: Sat, 27 May 2017 13:48:59 +0200 Subject: [PATCH] =?UTF-8?q?fix(core):=20allow=20null=20value=20for=20rende?= =?UTF-8?q?rer=20setElement(=E2=80=A6)=20(#17065)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using Renderer’s setElementAttribute or setElementStyle with a null or undefined value removes the corresponding attribute or style. The argument type should allow this when using strictNullChecks. Closes #13686 PR Close #17065 --- packages/core/src/render/api.ts | 4 ++-- packages/core/src/view/refs.ts | 4 ++-- tools/public_api_guard/core/core.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/src/render/api.ts b/packages/core/src/render/api.ts index 0a4a13ffb1..51b8b8cd58 100644 --- a/packages/core/src/render/api.ts +++ b/packages/core/src/render/api.ts @@ -73,7 +73,7 @@ export abstract class Renderer { abstract setElementProperty(renderElement: any, propertyName: string, propertyValue: any): void; - abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue: string): + abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue?: string): void; /** @@ -84,7 +84,7 @@ export abstract class Renderer { abstract setElementClass(renderElement: any, className: string, isAdd: boolean): void; - abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): void; + abstract setElementStyle(renderElement: any, styleName: string, styleValue?: string): void; abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]): void; diff --git a/packages/core/src/view/refs.ts b/packages/core/src/view/refs.ts index 4aa2eb4afb..6c86b4aca3 100644 --- a/packages/core/src/view/refs.ts +++ b/packages/core/src/view/refs.ts @@ -433,7 +433,7 @@ class RendererAdapter implements RendererV1 { this.delegate.setProperty(renderElement, propertyName, propertyValue); } - setElementAttribute(renderElement: Element, namespaceAndName: string, attributeValue: string): + setElementAttribute(renderElement: Element, namespaceAndName: string, attributeValue?: string): void { const [ns, name] = splitNamespace(namespaceAndName); if (attributeValue != null) { @@ -453,7 +453,7 @@ class RendererAdapter implements RendererV1 { } } - setElementStyle(renderElement: HTMLElement, styleName: string, styleValue: string): void { + setElementStyle(renderElement: HTMLElement, styleName: string, styleValue?: string): void { if (styleValue != null) { this.delegate.setStyle(renderElement, styleName, styleValue); } else { diff --git a/tools/public_api_guard/core/core.d.ts b/tools/public_api_guard/core/core.d.ts index 41d094a89f..437f4297a0 100644 --- a/tools/public_api_guard/core/core.d.ts +++ b/tools/public_api_guard/core/core.d.ts @@ -692,10 +692,10 @@ export declare abstract class Renderer { abstract projectNodes(parentElement: any, nodes: any[]): void; abstract selectRootElement(selectorOrNode: string | any, debugInfo?: RenderDebugInfo): any; abstract setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void; - abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue: string): void; + abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue?: string): void; abstract setElementClass(renderElement: any, className: string, isAdd: boolean): void; abstract setElementProperty(renderElement: any, propertyName: string, propertyValue: any): void; - abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): void; + abstract setElementStyle(renderElement: any, styleName: string, styleValue?: string): void; abstract setText(renderNode: any, text: string): void; }