Clean way to avoid escaping of quotes in JS in extraAttributes

Hi all

I'm using HtmlString when using JS in extraAttributes() but it's adding slashes before all single and double quotes. The only way I've been able to avoid that is by using Illuminate\Support\Js:

->extraAttributes([
   'x-on:click' => new HtmlString('$el.classList.add(' . Js::from('pointer-events-none') . ',' . Js::from('opacity-70') . ')'),
]);


Which isn't very readable... Is there a cleaner of doing this?
Solution
->extraAttributes(['x-on:click' => new HtmlString('$el.classList.add(\'pointer-events-none\', \'opacity-70\')')])


?
Was this page helpful?