Skip to content

Commit

Permalink
Fixed link_to "somewhere", :post => true to produce valid XHTML by us…
Browse files Browse the repository at this point in the history
…ing the parentnode instead of document.body for the instant form (closes #3007) [Bob Silva]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3928 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Mar 18, 2006
1 parent c2fb8ca commit 129a159
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form #3007 [Bob Silva]

* Added :function option to PrototypeHelper#observe_field/observe_form that allows you to call a function instead of submitting an ajax call as the trigger #4268 [jonathan@daikini.com]

* Make Mime::Type.parse consider q values (if any) [Jamis Buck]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def popup_javascript_function(popup)
end

def post_javascript_function
"var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();"
"var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();"
end

# Processes the _html_options_ hash, converting the boolean
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/template/url_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ def test_link_tag_with_popup_and_javascript_confirm

def test_link_tag_using_post_javascript
assert_dom_equal(
"<a href=\"http://www.example.com\" onclick=\"var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>",
"<a href=\"http://www.example.com\" onclick=\"var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>",
link_to("Hello", "http://www.example.com", :post => true)
)
end

def test_link_tag_using_post_javascript_and_confirm
assert_dom_equal(
"<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>",
"<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>",
link_to("Hello", "http://www.example.com", :post => true, :confirm => "Are you serious?")
)
end
Expand Down

0 comments on commit 129a159

Please sign in to comment.