Skip to content

Commit

Permalink
Fix rack-test to ignore maxlength="", closes teamcapybara#396
Browse files Browse the repository at this point in the history
  • Loading branch information
joliss committed Jul 8, 2011
1 parent f6c787e commit c51a232
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/capybara/rack_test/node.rb
Expand Up @@ -23,7 +23,10 @@ def set(value)
native.remove_attribute('checked')
end
elsif tag_name == 'input'
if (type == 'text' || type == 'password') && self[:maxlength]
if (type == 'text' || type == 'password') && self[:maxlength] &&
!self[:maxlength].empty?
# Browser behavior for maxlength="0" is inconsistent, so we stick with
# Firefox, allowing no input
value = value[0...self[:maxlength].to_i]
end
native['value'] = value.to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/views/form.erb
Expand Up @@ -50,7 +50,7 @@

<p>
<label>Street<br/>
<input type="text" name="form[street]" value="Sesame street 66"/>
<input type="text" maxlength="" name="form[street]" value="Sesame street 66"/>
</label>
</p>

Expand Down

0 comments on commit c51a232

Please sign in to comment.