Skip to content

Commit 8ea1770

Browse files
authored
Merge branch 'main' into add-tests-and-kwargs-support-for-remaining-actions
2 parents 5c6ce8f + 2845086 commit 8ea1770

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ import 'controllers'
149149

150150
### Browser History Actions
151151

152+
* `turbo_stream.history_back(**attributes)`
152153
* `turbo_stream.history_go(delta = 0, **attributes)`
153154
* `turbo_stream.push_state(url, title = "", state = {}, **attributes)`
154155
* `turbo_stream.replace_state(url, title = "", state = {}, **attributes)`

lib/turbo_power/stream_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ def set_title(title = nil, **attributes)
183183
end
184184

185185
# Browser History Actions
186+
187+
def history_back(**attributes)
188+
custom_action :history_back, attributes: attributes
189+
end
186190

187191
def history_go(delta = 0, **attributes)
188192
custom_action :history_go, attributes: attributes.reverse_merge(delta: delta)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
module TurboPower
6+
module StreamHelper
7+
class HistoryBackTest < StreamHelperTestCase
8+
test "history_back" do
9+
stream = %(<turbo-stream action="history_back"><template></template></turbo-stream>)
10+
11+
assert_dom_equal stream, turbo_stream.history_back
12+
end
13+
end
14+
end
15+
end

0 commit comments

Comments
 (0)