-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x-text doesn't work with SVG elements #734
Comments
That seems like a reasonable PR. Make sure to include a test. I don't know how exactly JSDOM works but I think it doesn't implement |
@philippbosch If you don't fancy doing a PR for this, I'll take a look on Sunday. |
Oh, I‘ll happily put together a PR. But thanks! |
Would we have issues if we always set textContent? |
I don't think so tbh, it should be fine. There are some differences in the behaviour of the two properties but I can't see any major problems. |
That was my first thought as well. What made me shy away from that approach was that the other But yeah, I can definitely look into using |
No worries, it was just to satisfy my curiosity. :) |
No, you're totally right, @SimoTod! Turns out that jsdom does not implement I'm gonna change the implementation of |
So, this PR is getting a lot more complex when we swap innerText for textContent. But I still think it‘s the right thing to do. jsdom has a pretty robust implementation of textContent but none at all of innerText. That means all tests that currently test something on innerText are not very realistic. Also, textContent – in jsdom and browsers – is always a string. So tests like this one need to be changed to expect Line 92 in 2db9cfb
I‘m going through all the tests and will update the PR tomorrow or on Monday. |
Scary changes |
I have an SVG image that is embedded in an HTML page inside an Alpine component. As part of the SVG there's a text element that I would like to bind to some Alpine data. Unfortunately,
x-text
does not seem to work for SVG elements.Example
I believe this is because
x-text
tries to set.innerText
on the element, but SVG elements, or at least<text>
don't have an.innerText
attribute.Something like this could work:
It's not the most elegant solution, but unless somebody has a better approach, I can put together a PR for this.
The text was updated successfully, but these errors were encountered: