Minor Changes
- ✨
mainElementPropertiesconfig: properties a worker script sets on DOM elements (such as a function an iframe's inlineonloadcalls) are also set on the real element, a function as a main thread function calling back into the worker. (by @Varixo in #776)
Patch Changes
-
🐞🩹
fetch(request)with aRequestobject keeps its method, headers, body and credentials instead of sending a GET to its URL (prebid's bid requests). (by @Varixo in #782) -
🐞🩹
postMessageon any iframe's window from the worker goes through its iframe element, also for about:blank frames the main thread has no partytown window for. (by @Varixo in #779) -
🐞🩹
hrefof<link>and<base>elements is read and set on the main thread again, so a stylesheet a worker script adds withlink.href = urlloads; the no-ophrefevery node has (for scripts walking up the tree) hid it. (by @Varixo in #780) -
🐞🩹 scripts loaded on the main thread via
loadScriptsOnMainThreadnow fire theload/errorhandlers registered on them in the worker (onload,onerror,addEventListener), so loaders that wait for them (e.g. gtag's Google Adsviewthroughconversion) complete (by @thegauravthakur in #771) -
🐞🩹 a worker
messagelistener can reply through theMessagePorts sent with the message (event.ports[0].postMessage), e.g. an ad library answering its creative's channel. (by @Varixo in #781) -
🐞🩹 in a worker
messagelistener,event.sourceof a message from one of the page's iframes is that iframe's window, so replies throughevent.source.postMessagereach it (e.g. a consent tool answering an ad's__tcfapicall). (by @Varixo in #779) -
🐞🩹 worker scripts can talk to a cross-origin iframe the browser loaded itself (no CORS):
iframe.contentWindow.postMessagereaches the frame, and the frame's reply toevent.sourcereaches the page'smessagelisteners instead of stopping at the partytown sandbox (e.g. a consent tool's consent store). (by @Varixo in #779) -
🐞🩹 window properties whose class partytown does not emulate, such as
cachesandscheduler, return the worker's own object instead of throwing "Illegal constructor". (by @Varixo in #778) -
🐞🩹 worker nodes get only the members every
Nodehas: elements no longer inheritTextmembers such assplitText, which made libraries that detect text nodes by it (preact) treat elements as text nodes. (by @Varixo in #777) -
🐞🩹 don't read partytown scripts before the window's environment has been sent to the worker. Scripts added during page load (e.g. by streaming SSR, picked up by the MutationObserver) or a
ptupdatebeforeloadwere sent to a worker with no environment for the window, failed, and were never run again (by @thegauravthakur in #767) -
🐞🩹 tabs that start Partytown in the same millisecond, e.g. waiting for the same service worker to activate, get different tab ids, so the service worker no longer sends one tab's requests to the other tab ("Error finding instance"). (by @gioboa in #783)
-
🐞🩹
window.eval(code)in a partytown script runs the code in the window's scope, like the script itself, instead of the worker's global scope wherewindow,documentand the page's globals are not defined (ad libraries run downloaded tags this way). (by @Varixo in #774) -
🐞🩹 define
CSSin the web worker:CSS.escape()runs in the worker, and every other member (CSS.supports(),CSS.registerProperty(), …) is forwarded to the main thread. Scripts like gtag that callCSS.escape()no longer throw (by @thegauravthakur in #773)