From b3c65bc8490b072a0d314aa3858c680fc6d67e35 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Fri, 18 Nov 2005 18:03:45 +0000 Subject: Use Element.update('id', 'html') instead of uid=501(sam) gid=501(sam) groups=501(sam), 81(appserveradm), 79(appserverusr), 80(admin).innerHTML = 'html' in JavaScriptGenerator#replace_html so that script tags are evaluated git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3086 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/prototype_helper.rb | 2 +- actionpack/test/template/prototype_helper_test.rb | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index e87733b611..6bdfec8ae1 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Use Element.update('id', 'html') instead of $('id').innerHTML = 'html' in JavaScriptGenerator#replace_html so that script tags are evaluated. [Sam Stephenson] + * Make rjs templates always implicitly skip out on layouts. [Marcel Molina Jr.] * Correct length for the truncate text helper. #2913 [Stefan Kaes] diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 74c32c7441..1ba607a90f 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -425,7 +425,7 @@ module ActionView # def replace_html(id, *options_for_render) html = render(*options_for_render) - record "$(#{id.inspect}).innerHTML = #{html.inspect}" + record "Element.update(#{id.inspect}, #{html.inspect})" end # Removes the DOM elements with the given +ids+ from the page. diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index c97aca5e79..c15280dcb3 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -167,7 +167,7 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase end def test_replace_html_with_string - assert_equal '$("element").innerHTML = "

This is a test

";', + assert_equal 'Element.update("element", "

This is a test

");', @generator.replace_html('element', '

This is a test

') end @@ -202,7 +202,7 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase new Insertion.Top("element", "

This is a test

"); new Insertion.Bottom("element", "

This is a test

"); ["foo", "bar"].each(Element.remove); -$("baz").innerHTML = "

This is a test

"; +Element.update("baz", "

This is a test

"); EOS end end -- cgit v1.2.3