(oldTag: Element, newTag: Element)
| 35 | * https://bugs.chromium.org/p/chromium/issues/detail?id=1211471#c12 |
| 36 | */ |
| 37 | export 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 | |
| 53 | function updateElements(type: string, components: JSX.Element[]) { |
| 54 | const headEl = document.querySelector('head') |
no test coverage detected