Skip to content

Commit

Permalink
Use cloneNode()
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Nov 10, 2021
1 parent c64f39f commit 5c9bfc4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/next/client/head-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ export function isEqualNode(oldTag: Element, newTag: Element) {
// Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
// be stripped if there is no content security policy response header that includes a nonce.
if (nonce && !oldTag.getAttribute('nonce')) {
// Remove nonce from HTML attribute for comparison
newTag.setAttribute('nonce', '')
newTag.nonce = nonce
const isEqual = nonce === oldTag.nonce && oldTag.isEqualNode(newTag)
// Restore original nonce
newTag.setAttribute('nonce', nonce)
return isEqual
const cloneTag = newTag.cloneNode(true) as typeof newTag
cloneTag.setAttribute('nonce', '')
cloneTag.nonce = nonce
return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag)
}
}

Expand Down

0 comments on commit 5c9bfc4

Please sign in to comment.