-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't recreate tags if they didn't change, closes #44
- Loading branch information
Showing
7 changed files
with
70 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Shamelessly taken from Next.js | ||
export function isEqualNode(oldTag: Element, newTag: Element) { | ||
if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) { | ||
const nonce = newTag.getAttribute('nonce') | ||
// 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')) { | ||
const cloneTag = newTag.cloneNode(true) as typeof newTag | ||
cloneTag.setAttribute('nonce', '') | ||
cloneTag.nonce = nonce | ||
return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag) | ||
} | ||
} | ||
|
||
return oldTag.isEqualNode(newTag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters