From 8ef195f9acf6918d4f29ff22d4453115c02adaf2 Mon Sep 17 00:00:00 2001 From: Robin North Date: Wed, 17 Jan 2018 19:12:12 +0000 Subject: [PATCH] Fix DOMException in switchElementsAlt() Clone attribute nodes before setting on `oldEl` to prevent the following error: ``` DOMException: Failed to execute 'setNamedItem' on 'NamedNodeMap': The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned. ``` --- lib/switches.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/switches.js b/lib/switches.js index d87ae0b..86beff3 100644 --- a/lib/switches.js +++ b/lib/switches.js @@ -22,7 +22,7 @@ module.exports = { if (newEl.hasAttributes()) { const attrs = newEl.attributes; for (var i = 0; i < attrs.length; i++) { - oldEl.attributes.setNamedItem(attrs[i]) + oldEl.attributes.setNamedItem(attrs[i].cloneNode()) } } -- 2.49.1