You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In WordPress/performance#1563 I'm attempting to integrate Partytown with popular WordPress plugins that add Google Analytics to the page. One popular plugin, WooCommerce, needs to access wp.i18n from the main thread specifically to obtain the translation string via wp.i18n.__(). However, this is currently blocked by Partytown in serializeObjectForWorker() because isValidMemberName() forbids serializing any properties beginning with _:
Describe the bug
In WordPress/performance#1563 I'm attempting to integrate Partytown with popular WordPress plugins that add Google Analytics to the page. One popular plugin, WooCommerce, needs to access
wp.i18n
from the main thread specifically to obtain the translation string viawp.i18n.__()
. However, this is currently blocked by Partytown inserializeObjectForWorker()
becauseisValidMemberName()
forbids serializing any properties beginning with_
:The members of
wp.i18n
are:__
_n
_nx
_x
createI18n
defaultI18n
getLocaleData
hasTranslation
isRTL
resetLocaleData
setLocaleData
sprintf
subscribe
It seems that
serializeObjectForWorker()
should be updated to only checkisValidMemberName()
for specific object types and not all objects.Reproduction
https://partytown-wp-i18n-failure.glitch.me/
Steps to reproduce
On a page add the following:
Then in the Partytown config, make this
my_i18n
object available to workers via themainWindowAccessors
configuration.Then attempt to call
my_i18n.__('...')
from a script that is running in a Worker.Browser Info
Chrome
Additional Information
No response
The text was updated successfully, but these errors were encountered: