JSON.parse error when wire:initial-data contained "
before renderWithRootAttribute
#152
Replies: 1 comment
-
For anyone who ends up here, newer version of the conflicting module was provided that uses |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey - sorry if this isn't the best place for such discussion. I wanted to also make this visible so others with similar issue could hopefully find this.
I have a question regarding responsibility for ensuring that wire:initial-data contains valid data, we have a 3rd party module that during "add_shipping_info" event in
\Amasty\GA4HyvaCheckout\Magewire\Checkout\CheckoutEventListener::evaluateCompletion
returnsThis
$eventData
contains some product name, stored after using$this->escaper->escapeHtml($productName)
, example below(note the"
)So now, the problem: later in magewirephp
\Magewirephp\Magewire\Model\Response::renderWithRootAttribute
is called and which encodes all other"
as"
which causesconst initialData = JSON.parse(this.el.getAttribute('wire:initial-data'))
to fail, because of unexpected"
character.I'm torn since Magento allows
"
characters in Product Names, I don't think it's fully Amasty's fault for using escapeHtml. For now we removed"
characters from production products until we provide a better fix or wait for Amasty to provide a fix so the the$eventData
always contains valid, supported by magewirephp data. I'm open to suggestions since ultimately the error is with encoded by Magewire data.The error:
Beta Was this translation helpful? Give feedback.
All reactions