Closed Yinci closed 3 years ago
@Yinci It's the default behaviour in Laravel. The '@' symbol has a specific meaning in blade files (You would get the same error with other frameworks): https://laravel.com/docs/8.x/blade#blade-and-javascript-frameworks
(TLDR: you need to use @@
)
(TLDR: you need to use
@@
)
That makes sense, but it also doesn't. How come it works 95% of the time, just not in this use case?
Do you have an example where it works in blade without escaping the @. It shouldn't work.
It shouldn't work.
I've been using @click
literally everywhere in my code. Only this time, upon a re-load of this particular code snippet, does it cause an exception. This code snippet works on first render. If this isn't intended behaviour, then it's weird that it's working on the first render, don't you think?
🤷♂️ The laravel documentation says to escape the @ symbol so I would follow it. I personally don't use that stack but other laravel devs should be able to tell you why some times it works and some times it doesn't. Nevertheless I suspect it's not an Alpine bug.
The laravel documentation says to escape the @ ...
That's fair enough! Makes sense, I just can't wrap my head around why it then would work in the first sense.
Nevertheless I suspect it's not an Alpine bug.
Anyhow, I suppose I'll close this as it's not really an issue, but perhaps it could be mentioned in the readme.
Re-opening this. I've been escaping @
ever since this issue (@@click
), but even then, it comes back.
Simply put: Refreshing a table that contains an @click
(escaped or not), results in this exception.
@Yinci This isn't an Alpine bug as @SimoTod said before. The problem is with morphdom (the DOM diffing library Livewire uses).
If you use the long hand equivalent, x:on
everything should work correctly.
Yeah, turns out element.setAttribute doesn't allow @ symbols. So any time morphdom tries to set a new @on attribute for any reason, the browser throws this error.
It's a pity because those attributes are perfectly fine in HTML when the element is created.
Will need to explore alternatives to .setAttribute if there are any
I am not entirely sure if this is more relevant to Alpine or to Livewire, but since the issue comes from Alpine I'll post it here;
For context: I have a table that displays users, and users can be softdeleted. On each user row, there are buttons to either delete or restore that user. See the code below:
Upon either deleting or restoring the user, the error
Uncaught (in promise) DOMException: String contains an invalid character
is triggered at line 13 in Livewire.js according to the console. This breaks the whole page.When changing
@
tox-on:
there is no issue.Versions: Firefox: 87.0 (64 bits) Laravel: 8.21.0 Livewire: 2.3.0 AlpineJS: 2.8.2