-
Notifications
You must be signed in to change notification settings - Fork 57
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
assert_dom :text collapses whitespace #123
base: main
Are you sure you want to change the base?
assert_dom :text collapses whitespace #123
Conversation
There seems to be an issue with the CI workflows related to the Logger gem. I'll fix it on |
OK, |
So to confirm, you won't both PRs merged, not just this one? I made the two PRs so that there were a couple of options for how this would be implemented, with the intention that only one would get chosen. Let me know what you think is best. I should probably also update the commented docs just before the |
I just want whatever you want to submit rebased so I can see if the tests pass, please! Or let me know if you want me to do it, that's fine, too. I'm sorry I've been busy this week, but in general I want to see:
and we're still on that first item until the branch is rebased on the current |
Ahhh right sorry for some reason I read "rebase" as merge the pull request. I'll rebase now. |
27f1469
to
c052922
Compare
@flavorjones Rebased and tests and ci is passing |
Fixes #121
This PR is my preferred solution over #122.
Instead of making use of a
:strict
operator to determine whether or not to collapse excess whitespace as the browser does, we instead use the existing:html
equality operator to match for text with all whitespace included. The:text
equality operator is then optimised to collapse all whitespace.In my opinion,
:text
should match what would be returned byElement.innerText
in javascript land, in that it does not include the excess whitespace.Element.innerHTML
on the other hand, does include all of the whitespace that was in the document which I think is what the:html
operator should match (which it does already) and so:html
could instead be used as a:strict
parameter.The only difference between what
Element.innerText
and the updated:text
equality operator does is thatElement.innerText
replaces<br>
tags with\n
, whereas our:text
operator just removes them without replacing them. But this is out of our control as it is Nokogiri that does this. Regardless, this is my preferred solution but I made the two PRs since the original issue I raised specifically mentions astrict
parameter.