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.
```
This commit was merged in pull request #104.
This commit is contained in:
Robin North
2018-01-17 19:12:12 +00:00
committed by BehindTheMath
parent 36ed7079b1
commit b98e3ef914

View File

@@ -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())
}
}