Permalink
Browse files

Revert "Simplify JavaScriptHelper#escape_javascript"

This commit broke the build without any improvement.

This reverts commit eb0b714.
  • Loading branch information...
spastorino committed Aug 24, 2011
1 parent 5493d22 commit 289540e4ffc1a5619979708e5287a9b71f9ab4e2
Showing with 6 additions and 4 deletions.
  1. +6 −4 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -26,10 +26,12 @@ module JavaScriptHelper
#
# $('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

0 comments on commit 289540e

Please sign in to comment.