From dccd3d4800e635875b0cb9aaee9dc9eb466e9973 Mon Sep 17 00:00:00 2001 From: paldepind Date: Sat, 17 Dec 2016 13:17:49 +0100 Subject: [PATCH] Satisfy strict null checks --- src/helpers/attachto.ts | 6 ++++-- src/htmldomapi.ts | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/helpers/attachto.ts b/src/helpers/attachto.ts index e0f5ee9..eaeff2d 100755 --- a/src/helpers/attachto.ts +++ b/src/helpers/attachto.ts @@ -16,7 +16,9 @@ function post(_: any, vnode: VNode): void { function destroy(vnode: VNode): void { // Remove placeholder - vnode.elm && vnode.elm.parentElement.removeChild(vnode.elm); + if (vnode.elm !== undefined) { + (vnode.elm.parentElement as HTMLElement).removeChild(vnode.elm); + } // Remove real element from where it was inserted vnode.elm = (vnode.data as VNodeData).attachData.real; } @@ -44,4 +46,4 @@ export function attachTo(target: Element, vnode: VNode): VNode { hook.destroy = destroy; return vnode; }; -export default attachTo; \ No newline at end of file +export default attachTo; diff --git a/src/htmldomapi.ts b/src/htmldomapi.ts index 2cc2938..f3973a7 100644 --- a/src/htmldomapi.ts +++ b/src/htmldomapi.ts @@ -35,11 +35,11 @@ function appendChild(node: Node, child: Node): void { node.appendChild(child); } -function parentNode(node: Node): HTMLElement { +function parentNode(node: Node): HTMLElement | null { return node.parentElement; } -function nextSibling(node: Node): Node { +function nextSibling(node: Node): Node | null { return node.nextSibling; } @@ -63,4 +63,5 @@ export const htmlDomApi = { tagName, setTextContent, } as DOMAPI; -export default htmlDomApi; \ No newline at end of file + +export default htmlDomApi;