From 289540e4ffc1a5619979708e5287a9b71f9ab4e2 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 24 Aug 2011 13:21:18 -0300 Subject: Revert "Simplify JavaScriptHelper#escape_javascript" This commit broke the build without any improvement. This reverts commit eb0b71478ad4c37fdc4ec77bf2cf7c6b65dd36c4. --- actionpack/lib/action_view/helpers/javascript_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'actionpack') 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 -- cgit v1.2.3