From 7e679e3cc3844a91f0f5d0f7761f01400ded9de1 Mon Sep 17 00:00:00 2001 From: Sunpy Date: Tue, 21 Apr 2020 15:14:04 +0200 Subject: [PATCH] Class & id transfer when node swapping --- sunpy/node/nodes/swapnode.js | 6 ++++++ tests/init.html | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sunpy/node/nodes/swapnode.js b/sunpy/node/nodes/swapnode.js index d698447..82aa5c8 100644 --- a/sunpy/node/nodes/swapnode.js +++ b/sunpy/node/nodes/swapnode.js @@ -16,6 +16,12 @@ export class SwapNode extends BaseNode { if (this.hasReplaceNodes) return false; + // Copy id and classes to new node + if (this.node.id) + this.swapNode.id = this.node.id; + if (this.node.classList.length) + this.swapNode.classList = this.node.classList; + this.linker(this.node, this.swapNode); this.node.parentNode.replaceChild(this.swapNode, this.node); diff --git a/tests/init.html b/tests/init.html index 5cd3603..d64ae1b 100644 --- a/tests/init.html +++ b/tests/init.html @@ -21,10 +21,10 @@ - -