<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -407,6 +407,7 @@ module ActionController
 
           if rjs_type == :insert
             arg = args.shift
+            position  = arg
             insertion = &quot;insert_#{arg}&quot;.to_sym
             raise ArgumentError, &quot;Unknown RJS insertion type #{arg}&quot; unless RJS_STATEMENTS[insertion]
             statement = &quot;(#{RJS_STATEMENTS[insertion]})&quot;
@@ -418,6 +419,7 @@ module ActionController
         else
           statement = &quot;#{RJS_STATEMENTS[:any]}&quot;
         end
+        position ||= Regexp.new(RJS_INSERTIONS.join('|'))
 
         # Next argument we're looking for is the element identifier. If missing, we pick
         # any element.
@@ -434,9 +436,14 @@ module ActionController
               Regexp.new(&quot;\\$\\(\&quot;#{id}\&quot;\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)&quot;, Regexp::MULTILINE)
             when :remove, :show, :hide, :toggle
               Regexp.new(&quot;#{statement}\\(\&quot;#{id}\&quot;\\)&quot;)
-            else
-              Regexp.new(&quot;#{statement}\\(\&quot;#{id}\&quot;, #{RJS_PATTERN_HTML}\\)&quot;, Regexp::MULTILINE)
-          end
+            when :replace, :replace_html
+              Regexp.new(&quot;#{statement}\\(\&quot;#{id}\&quot;, #{RJS_PATTERN_HTML}\\)&quot;)
+            when :insert, :insert_html
+              Regexp.new(&quot;Element.insert\\(\\\&quot;#{id}\\\&quot;, \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);&quot;)
+             else
+              Regexp.union(Regexp.new(&quot;#{statement}\\(\&quot;#{id}\&quot;, #{RJS_PATTERN_HTML}\\)&quot;),
+                Regexp.new(&quot;Element.insert\\(\\\&quot;#{id}\\\&quot;, \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);&quot;))
+           end
 
         # Duplicate the body since the next step involves destroying it.
         matches = nil
@@ -445,7 +452,7 @@ module ActionController
             matches = @response.body.match(pattern)
           else
             @response.body.gsub(pattern) do |match|
-              html = unescape_rjs($2)
+              html = unescape_rjs(match)
               matches ||= []
               matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? }
               &quot;&quot;
@@ -585,17 +592,16 @@ module ActionController
             :hide                 =&gt; /Element\.hide/,
             :toggle                 =&gt; /Element\.toggle/
           }
+          RJS_STATEMENTS[:any] = Regexp.new(&quot;(#{RJS_STATEMENTS.values.join('|')})&quot;)
+          RJS_PATTERN_HTML = /&quot;((\\&quot;|[^&quot;])*)&quot;/
           RJS_INSERTIONS = [:top, :bottom, :before, :after]
           RJS_INSERTIONS.each do |insertion|
-            RJS_STATEMENTS[&quot;insert_#{insertion}&quot;.to_sym] = Regexp.new(Regexp.quote(&quot;new Insertion.#{insertion.to_s.camelize}&quot;))
+            RJS_STATEMENTS[&quot;insert_#{insertion}&quot;.to_sym] = /Element.insert\(\&quot;([^\&quot;]*)\&quot;, \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/
           end
-          RJS_STATEMENTS[:any] = Regexp.new(&quot;(#{RJS_STATEMENTS.values.join('|')})&quot;)
           RJS_STATEMENTS[:insert_html] = Regexp.new(RJS_INSERTIONS.collect do |insertion|
-            Regexp.quote(&quot;new Insertion.#{insertion.to_s.camelize}&quot;)
+            /Element.insert\(\&quot;([^\&quot;]*)\&quot;, \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/
           end.join('|'))
-          RJS_PATTERN_HTML = /&quot;((\\&quot;|[^&quot;])*)&quot;/
-          RJS_PATTERN_EVERYTHING = Regexp.new(&quot;#{RJS_STATEMENTS[:any]}\\(\&quot;([^\&quot;]*)\&quot;, #{RJS_PATTERN_HTML}\\)&quot;,
-                                              Regexp::MULTILINE)
+          RJS_PATTERN_EVERYTHING = Regexp.new(&quot;#{RJS_STATEMENTS[:any]}\\(\&quot;([^\&quot;]*)\&quot;, #{RJS_PATTERN_HTML}\\)&quot;, Regexp::MULTILINE)
           RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
         end
 </diff>
      <filename>actionpack/lib/action_controller/assertions/selector_assertions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -608,7 +608,7 @@ module ActionView
         # Example:
         #
         #   # Generates:
-        #   #     new Insertion.Bottom(&quot;list&quot;, &quot;&lt;li&gt;Some item&lt;/li&gt;&quot;);
+        #   #     new Element.insert(&quot;list&quot;, { bottom: &lt;li&gt;Some item&lt;/li&gt;&quot; });
         #   #     new Effect.Highlight(&quot;list&quot;);
         #   #     [&quot;status-indicator&quot;, &quot;cancel-link&quot;].each(Element.hide);
         #   update_page do |page|
@@ -741,16 +741,16 @@ module ActionView
           #
           #   # Insert the rendered 'navigation' partial just before the DOM
           #   # element with ID 'content'.
-          #   # Generates: new Insertion.Before(&quot;content&quot;, &quot;-- Contents of 'navigation' partial --&quot;);
+          #   # Generates: Element.insert(&quot;content&quot;, { before: &quot;-- Contents of 'navigation' partial --&quot; });
           #   page.insert_html :before, 'content', :partial =&gt; 'navigation'
           #
           #   # Add a list item to the bottom of the &lt;ul&gt; with ID 'list'.
-          #   # Generates: new Insertion.Bottom(&quot;list&quot;, &quot;&lt;li&gt;Last item&lt;/li&gt;&quot;);
+          #   # Generates: Element.insert(&quot;list&quot;, { bottom: &quot;&lt;li&gt;Last item&lt;/li&gt;&quot; });
           #   page.insert_html :bottom, 'list', '&lt;li&gt;Last item&lt;/li&gt;'
           #
           def insert_html(position, id, *options_for_render)
-            insertion = position.to_s.camelize
-            call &quot;new Insertion.#{insertion}&quot;, id, render(*options_for_render)
+            content = javascript_object_for(render(*options_for_render))
+            record &quot;Element.insert(\&quot;#{id}\&quot;, { #{position.to_s.downcase}: #{content} });&quot;
           end
 
           # Replaces the inner HTML of the DOM element with the given +id+.
@@ -1054,7 +1054,7 @@ module ActionView
 
         js_options['asynchronous'] = options[:type] != :synchronous
         js_options['method']       = method_option_to_s(options[:method]) if options[:method]
-        js_options['insertion']    = &quot;Insertion.#{options[:position].to_s.camelize}&quot; if options[:position]
+        js_options['insertion']    = options[:position].to_s.downcase if options[:position]
         js_options['evalScripts']  = options[:script].nil? || options[:script]
 
         if options[:form]</diff>
      <filename>actionpack/lib/action_view/helpers/prototype_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -287,13 +287,13 @@ class JavaScriptGeneratorTest &lt; PrototypeHelperBaseTest
   end
 
   def test_insert_html_with_string
-    assert_equal 'new Insertion.Top(&quot;element&quot;, &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot;);',
+    assert_equal 'Element.insert(&quot;element&quot;, { top: &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot; });',
       @generator.insert_html(:top, 'element', '&lt;p&gt;This is a test&lt;/p&gt;')
-    assert_equal 'new Insertion.Bottom(&quot;element&quot;, &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot;);',
+    assert_equal 'Element.insert(&quot;element&quot;, { bottom: &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot; });',
       @generator.insert_html(:bottom, 'element', '&lt;p&gt;This is a test&lt;/p&gt;')
-    assert_equal 'new Insertion.Before(&quot;element&quot;, &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot;);',
+    assert_equal 'Element.insert(&quot;element&quot;, { before: &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot; });',
       @generator.insert_html(:before, 'element', '&lt;p&gt;This is a test&lt;/p&gt;')
-    assert_equal 'new Insertion.After(&quot;element&quot;, &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot;);',
+    assert_equal 'Element.insert(&quot;element&quot;, { after: &quot;\\u003Cp\u003EThis is a test\\u003C/p\u003E&quot; });',
       @generator.insert_html(:after, 'element', '&lt;p&gt;This is a test&lt;/p&gt;')
   end
 
@@ -366,8 +366,8 @@ class JavaScriptGeneratorTest &lt; PrototypeHelperBaseTest
     @generator.replace_html('baz', '&lt;p&gt;This is a test&lt;/p&gt;')
 
     assert_equal &lt;&lt;-EOS.chomp, @generator.to_s
-new Insertion.Top(&quot;element&quot;, &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot;);
-new Insertion.Bottom(&quot;element&quot;, &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot;);
+Element.insert(&quot;element&quot;, { top: &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot; });
+Element.insert(&quot;element&quot;, { bottom: &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot; });
 [&quot;foo&quot;, &quot;bar&quot;].each(Element.remove);
 Element.update(&quot;baz&quot;, &quot;\\u003Cp\\u003EThis is a test\\u003C/p\\u003E&quot;);
     EOS</diff>
      <filename>actionpack/test/template/prototype_helper_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c8e80f6389b45134c0514dde6736488cf5507765</id>
    </parent>
  </parents>
  <author>
    <name>miloops</name>
    <email>miloops@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/eaab895f83276674891227c656df9b4cebc50200</url>
  <id>eaab895f83276674891227c656df9b4cebc50200</id>
  <committed-date>2008-07-30T01:42:32-07:00</committed-date>
  <authored-date>2008-07-22T07:13:38-07:00</authored-date>
  <message>Prototype helpers should generate Element.insert instead of Insertion.new, which has been deprecated in Prototype 1.6.</message>
  <tree>04abcb82319b12701ca8690dc829a9fe6b375e98</tree>
  <committer>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </committer>
</commit>
