Skip to content

Commit b6d6e25

Browse files
committed
Fix unescape_js to match changes in Action View
Unescapes dollar signs and backticks added by rails/rails@033a738
1 parent 7553142 commit b6d6e25

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/jquery/assert_select.rb

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def unescape_js(js_string)
124124
unescaped.gsub!('\n', "\n")
125125
unescaped.gsub!('\076', '>')
126126
unescaped.gsub!('\074', '<')
127+
unescaped.gsub!(/\\\$/, '$')
128+
unescaped.gsub!(/\\`/, '`')
127129
# js encodes non-ascii characters.
128130
unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
129131
unescaped

test/assert_select_jquery_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
2323
2424
// without semicolon
2525
$("#browser_cart").hide("blind", 1000)
26+
27+
$('#item').html('<div><span>\\`Total\\`: \\$12.34</span></div>');
2628
JS
2729

2830
setup do
@@ -43,6 +45,10 @@ def test_target_as_receiver
4345
assert_select_jquery :remove, "#cart tr:not(.total_line) > *"
4446
assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]"
4547
assert_select_jquery :remove, "tr + td, li"
48+
49+
assert_select_jquery :html, '#item' do
50+
assert_select 'span', '`Total`: $12.34'
51+
end
4652
end
4753

4854
assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do

0 commit comments

Comments
 (0)