MCPcopy
hub / github.com/vercel/next.js / isEqualNode

Function isEqualNode

packages/next/src/client/head-manager.ts:37–51  ·  view source on GitHub ↗
(oldTag: Element, newTag: Element)

Source from the content-addressed store, hash-verified

35 * https://bugs.chromium.org/p/chromium/issues/detail?id=1211471#c12
36 */
37export function isEqualNode(oldTag: Element, newTag: Element) {
38 if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) {
39 const nonce = newTag.getAttribute('nonce')
40 // Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
41 // be stripped if there is no content security policy response header that includes a nonce.
42 if (nonce && !oldTag.getAttribute('nonce')) {
43 const cloneTag = newTag.cloneNode(true) as typeof newTag
44 cloneTag.setAttribute('nonce', '')
45 cloneTag.nonce = nonce
46 return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag)
47 }
48 }
49
50 return oldTag.isEqualNode(newTag)
51}
52
53function updateElements(type: string, components: JSX.Element[]) {
54 const headEl = document.querySelector('head')

Callers 2

updateElementsFunction · 0.85

Calls 2

getAttributeMethod · 0.80
setAttributeMethod · 0.45

Tested by

no test coverage detected