Skip to content

Commit

Permalink
Merge pull request #1284 from itutto/master
Browse files Browse the repository at this point in the history
Fix: Fragile cloneNode implementation
  • Loading branch information
capricorn86 authored Mar 10, 2024
2 parents 10c7617 + ee1c28a commit 1eaa5f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/happy-dom/src/nodes/element/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ export default class Element extends Node implements IElement {
public cloneNode(deep = false): IElement {
const clone = <Element>super.cloneNode(deep);

clone[PropertySymbol.tagName] = this[PropertySymbol.tagName];
clone[PropertySymbol.localName] = this[PropertySymbol.localName];
clone[PropertySymbol.namespaceURI] = this[PropertySymbol.namespaceURI];

for (let i = 0, max = this[PropertySymbol.attributes].length; i < max; i++) {
const attribute = this[PropertySymbol.attributes][i];
clone[PropertySymbol.attributes].setNamedItem(
Expand All @@ -488,10 +492,6 @@ export default class Element extends Node implements IElement {
}
}

clone[PropertySymbol.tagName] = this[PropertySymbol.tagName];
clone[PropertySymbol.localName] = this[PropertySymbol.localName];
clone[PropertySymbol.namespaceURI] = this[PropertySymbol.namespaceURI];

return <IElement>clone;
}

Expand Down

0 comments on commit 1eaa5f5

Please sign in to comment.