Skip to content

Commit

Permalink
Don't deprecate HTML options, just delete :event_name
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolalsvk committed Oct 14, 2017
1 parent 11243fa commit 629953f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/views/render_async/_render_async.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
document.getElementById("<%= container_id %>").outerHTML = request.responseText;

<% if event_name.present? %>
document.dispatchEvent(new Event("<%= event_name %>", response));
document.dispatchEvent(new Event("<%= event_name %>"));
<% end %>
}
};
Expand Down
5 changes: 3 additions & 2 deletions lib/render_async/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ def render_async_cache(path, options = {})

def render_async(path, options = {}, &placeholder)
container_id = "render_async_#{SecureRandom.hex(5)}#{Time.now.to_i}"
event_name = options.delete(:event_name)
placeholder = capture(&placeholder) if block_given?

render 'render_async/render_async', container_id: container_id,
path: path,
html_options: options[:html],
event_name: options[:event_name],
html_options: options,
event_name: event_name,
placeholder: placeholder
end

Expand Down
9 changes: 5 additions & 4 deletions spec/render_async/view_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
:container_id => /render_async_/,
:path => "users",
:html_options => {},
:event_name => nil,
:placeholder => nil
}
)
Expand All @@ -66,7 +67,7 @@
{
:container_id => /render_async_/,
:path => "users",
:html_options => nil,
:html_options => {},
:event_name => nil,
:placeholder => nil
}
Expand All @@ -89,7 +90,7 @@
}
)

helper.render_async("users", :html => { :nonce => "jkg1935safd" })
helper.render_async("users", :nonce => "jkg1935safd")
end
end

Expand All @@ -100,7 +101,7 @@
{
:container_id => /render_async_/,
:path => "users",
:html_options => nil,
:html_options => {},
:event_name => "render_async_done",
:placeholder => nil
}
Expand All @@ -123,7 +124,7 @@
{
:container_id => /render_async_/,
:path => "users",
:html_options => nil,
:html_options => {},
:event_name => nil,
:placeholder => placeholder
}
Expand Down

0 comments on commit 629953f

Please sign in to comment.