From 7f82adb211a527613c5f2e1ffd9cfc10be864aae Mon Sep 17 00:00:00 2001 From: Thomas Holloway Date: Tue, 19 Jan 2021 22:02:08 -0600 Subject: [PATCH] Fix template default strategy to check for top and bottom buffer elements before removing --- src/template-strategy-default.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/template-strategy-default.ts b/src/template-strategy-default.ts index cf82481..b4de543 100644 --- a/src/template-strategy-default.ts +++ b/src/template-strategy-default.ts @@ -31,8 +31,12 @@ export class DefaultTemplateStrategy implements ITemplateStrategy { removeBuffers(el: Element, topBuffer: Element, bottomBuffer: Element): void { const parent = el.parentNode; - parent.removeChild(topBuffer); - parent.removeChild(bottomBuffer); + if (parent.contains(topBuffer)) { + parent.removeChild(topBuffer); + } + if (parent.contains(bottomBuffer)) { + parent.removeChild(bottomBuffer); + } } getFirstElement(topBuffer: Element, bottomBuffer: Element): Element {