diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-08-24 13:21:18 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-08-24 13:22:37 -0300 |
commit | 289540e4ffc1a5619979708e5287a9b71f9ab4e2 (patch) | |
tree | 65cb75166d66d53f92003b35d23ee22eac5b1f20 /actionpack | |
parent | 5493d22419913c279a8baf38a10ffe6a9782c274 (diff) | |
download | rails-289540e4ffc1a5619979708e5287a9b71f9ab4e2.tar.gz rails-289540e4ffc1a5619979708e5287a9b71f9ab4e2.tar.bz2 rails-289540e4ffc1a5619979708e5287a9b71f9ab4e2.zip |
Revert "Simplify JavaScriptHelper#escape_javascript"
This commit broke the build without any improvement.
This reverts commit eb0b71478ad4c37fdc4ec77bf2cf7c6b65dd36c4.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index d01e62378b..1adcd716f8 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -26,10 +26,12 @@ module ActionView # # $('some_element').replaceWith('<%=j render 'some/element_template' %>'); def escape_javascript(javascript) - return "" if javascript.empty? - - result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] } - javascript.html_safe? ? result.html_safe : result + if javascript + result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] } + javascript.html_safe? ? result.html_safe : result + else + '' + end end alias_method :j, :escape_javascript |