-
-
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
Make x-text work on SVG elements #736
Make x-text work on SVG elements #736
Conversation
There's some other failing tests that were checking innerText, a search and replace of innerText to textContent should fix them. |
@HugoDF I'm on it. There's much more to it. |
446b7c9
to
f2d849e
Compare
f2d849e
to
e72737f
Compare
So, I changed all the tests to work on There are three kinds of changes to the tests:
I am torn about whether this is what we want. Especially no. 3 is really confusing I find. One idea I had about that was that instead of testing for equality ( What do you think? @HugoDF @ryangjchandler @SimoTod |
@philippbosch - I personally think that having a custom matcher is a bit overkill. The tests are pretty clear in what they do, since we are actually making assertions against a string so it's all regular JavaScript behaviour, I can't see any need for the custom matcher. See what the other guys think though. |
My 2 pence: I think the current tests are not real because jest doesn't support innerText. If you use it in a real browser |
@calebporzio Here's the tl;dr: I want to make Line 92 in 12b2da3
I propose to adjust all the tests and swap out |
Totally agree. Good PR. .textContent ftw! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found 2-3 instances where the test didn't need to be updated, I think it's fine to update them to be fair, just thought I would point them out.
@HugoDF yeah, I saw these but thought it made sense to also change them for the sake of consistency |
Makes sense |
The
x-text
directive setsinnerText
on the element. The problem is thatinnerText
is only available on elements based onHTMLElement
but notSVGElement
which is the base for e.g. the<text>
SVG element.So instead of blindly settingel.innerText
we now first check if it's actually an HTML element and otherwise fall back to settingel.textContent
which is part of theNode
interface that all elements are based on.Based on the discussion in #734, this PR swaps
innerText
out fortextContent
because they behave identically (at least when setting the value) and the latter is part of theNode
interface that all elements – HTML and SVG – are based on.Fixes #734