Skip to content

Commit

Permalink
Revert "Return html inside textareas when page is loaded. Closes #1025"
Browse files Browse the repository at this point in the history
It seems like textareas must not contain HTML content according to the
HTML spec.

This reverts commit ca4781f.

Conflicts:
	lib/capybara/spec/session/node_spec.rb
  • Loading branch information
jnicklas committed Mar 27, 2013
1 parent 6ce45f2 commit 2d5c8e0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/capybara/node/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def path
#
def value
if tag_name == 'textarea'
native.inner_html.sub(/\A\n/, '')
native.content.sub(/\A\n/, '')
elsif tag_name == 'select'
if native['multiple'] == 'multiple'
native.xpath(".//option[@selected='selected']").map { |option| option[:value] || option.content }
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/rack_test/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def params(button)
merge_param!(params, field['name'].to_s, (option['value'] || option.text).to_s) if option
end
when 'textarea'
merge_param!(params, field['name'].to_s, field.inner_html.to_s)
merge_param!(params, field['name'].to_s, field.text.to_s)
end
end
merge_param!(params, button[:name], button[:value] || "") if button[:name]
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/rack_test/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def set(value)
elsif input_field?
set_input(value)
elsif textarea?
native.inner_html = value.to_s unless self[:readonly]
native.content = value.to_s unless self[:readonly]
end
end

Expand Down
6 changes: 1 addition & 5 deletions lib/capybara/spec/session/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@
@session.find('//textarea[@id="additional_newline"]').value.should == "\nbanana"
end

it "return any HTML content added to textarea" do
it "return any HTML content in textarea" do
@session.find('//textarea[1]').set("some <em>html</em> here")
@session.find('//textarea[1]').value.should == "some <em>html</em> here"
end

it "return any HTML content in textarea" do
@session.find(:css, 'textarea#with-html').value.should == "contains <em>html</em>"
end
end

describe "#set" do
Expand Down
1 change: 0 additions & 1 deletion lib/capybara/spec/views/with_html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ banana</textarea>

banana</textarea>
<textarea readonly="readonly">textarea should not change</textarea>
<textarea id="with-html">contains <em>html</em></textarea>
<a href="/redirect_back">BackToMyself</a>
<a title="twas a fine link" href="/redirect">A link came first</a>
<a title="a fine link" href="/with_simple_html">A link</a>
Expand Down

0 comments on commit 2d5c8e0

Please sign in to comment.