Skip to content

Commit 4241aa0

Browse files
jyeharryrafaelfranca
authored andcommitted
Collapse whitespace from :text but not :html
1 parent 57d49a5 commit 4241aa0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def initialize(values, previous_selection = nil, refute: false, &root_fallback)
1818
@values = values
1919
@root = extract_root(previous_selection, root_fallback)
2020
extract_selectors
21-
@strict = false
2221
@tests = extract_equality_tests(refute)
2322
@message = @values.shift
2423

@@ -52,15 +51,16 @@ def filter(matches)
5251

5352
content_mismatch = nil
5453
text_matches = tests.has_key?(:text)
54+
html_matches = tests.has_key?(:html)
5555
regex_matching = match_with.is_a?(Regexp)
5656

5757
remaining = matches.reject do |match|
5858
# Preserve markup with to_s for html elements
59-
content = text_matches ? match.text : match.children.to_s
59+
content = text_matches ? match.text : match.inner_html
6060

6161
content.strip! unless NO_STRIP.include?(match.name)
6262
content.delete_prefix!("\n") if text_matches && match.name == "textarea"
63-
collapse_html_whitespace!(content) unless NO_STRIP.include?(match.name) || @strict
63+
collapse_html_whitespace!(content) unless NO_STRIP.include?(match.name) || html_matches
6464

6565
next if regex_matching ? (content =~ match_with) : (content == match_with)
6666
content_mismatch ||= diff(match_with, content)

0 commit comments

Comments
 (0)