Skip to content

Commit

Permalink
Fix - Prevent adding of data-disable-with option twice in html.
Browse files Browse the repository at this point in the history
Earlier
when `data-disable-with` option is added direclty as in options then

```ruby
submit_tag("Save", { "data-disable-with" => "Processing..." })
# => <input type="submit" name="commit" value="Save" data-disable-with="Processing..." data-disable-with="Processing..." />
```

Now
when `data-disable-with` option is added direclty as in options then

```ruby
submit_tag("Save", { "data-disable-with" => "Processing..." })
# => <input type="submit" name="commit" value="Save" data-disable-with="Processing..." />
```
  • Loading branch information
Akshay Vishnoi committed Sep 18, 2015
1 parent 95593f0 commit 9331f00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/form_tag_helper.rb
Expand Up @@ -450,9 +450,9 @@ def submit_tag(value = "Save changes", options = {})
disable_with_text ||= value.clone
tag_options.deep_merge!("data" => { "disable_with" => disable_with_text })
else
tag_options.delete("data-disable-with")
tag_options["data"].delete(:disable_with) if tag_options["data"]
end
tag_options.delete("data-disable-with")
end

tag :input, tag_options
Expand Down
8 changes: 8 additions & 0 deletions actionview/test/template/form_tag_helper_test.rb
Expand Up @@ -485,6 +485,14 @@ def test_submit_tag_with_confirmation
)
end

def test_submit_tag_doesnt_have_data_disable_with_twice
assert_equal(
%(<input type="submit" name="commit" value="Save" data-confirm="Are you sure?" data-disable-with="Processing..." />),
submit_tag("Save", { "data-disable-with" => "Processing...", "data-confirm" => "Are you sure?" })
)
end


def test_button_tag
assert_dom_equal(
%(<button name="button" type="submit">Button</button>),
Expand Down

0 comments on commit 9331f00

Please sign in to comment.