turbo_boost-commands 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of turbo_boost-commands might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/app/assets/builds/@turbo-boost/commands.js +3 -4
- data/app/assets/builds/@turbo-boost/commands.js.map +4 -4
- data/app/javascript/drivers/index.js +2 -1
- data/app/javascript/elements.js +7 -3
- data/app/javascript/lifecycle.js +1 -0
- data/lib/turbo_boost/commands/attribute_hydration.rb +6 -0
- data/lib/turbo_boost/commands/command_callbacks.rb +4 -0
- data/lib/turbo_boost/commands/controller_pack.rb +1 -0
- data/lib/turbo_boost/commands/runner.rb +14 -3
- data/lib/turbo_boost/commands/version.rb +1 -1
- metadata +6 -6
@@ -12,7 +12,8 @@ function src (element, frame) {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
function find (element) {
|
15
|
-
let frame = elements.
|
15
|
+
let frame = elements.findClosestFrameWithSource(element)
|
16
|
+
|
16
17
|
const { turboFrame, turboMethod } = element.dataset
|
17
18
|
|
18
19
|
if (element.tagName.toLowerCase() === 'form')
|
data/app/javascript/elements.js
CHANGED
@@ -5,8 +5,12 @@ function findClosestCommand (element) {
|
|
5
5
|
return element.closest(`[${schema.commandAttribute}]`)
|
6
6
|
}
|
7
7
|
|
8
|
-
function
|
9
|
-
return
|
8
|
+
function findClosestFrameWithSource (element) {
|
9
|
+
return (
|
10
|
+
element.closest('turbo-frame[src]') ||
|
11
|
+
element.closest('turbo-frame[data-turbo-frame-src]') ||
|
12
|
+
element.closest('turbo-frame')
|
13
|
+
)
|
10
14
|
}
|
11
15
|
|
12
16
|
function assignElementValueToPayload (element, payload = {}) {
|
@@ -47,5 +51,5 @@ function buildAttributePayload (element) {
|
|
47
51
|
export default {
|
48
52
|
buildAttributePayload,
|
49
53
|
findClosestCommand,
|
50
|
-
|
54
|
+
findClosestFrameWithSource
|
51
55
|
}
|
data/app/javascript/lifecycle.js
CHANGED
@@ -24,6 +24,12 @@ module TurboBoost::Commands::AttributeHydration
|
|
24
24
|
value
|
25
25
|
end
|
26
26
|
|
27
|
+
# RULE: If an attribute value is a Hash
|
28
|
+
# (not the `aria` or `data` key because those are handled by Rails)
|
29
|
+
# and the Hash does not contain an object that implements GlobalID,
|
30
|
+
# then the developer must convert the Hash to a JSON string manually.
|
31
|
+
#
|
32
|
+
# SOLUTION: All data that's not a scalar/primitive value should live in `data` or `aria`.
|
27
33
|
def dehydrate(value)
|
28
34
|
return value unless has_sgid?(value)
|
29
35
|
case value
|
@@ -93,6 +93,10 @@ class TurboBoost::Commands::Runner
|
|
93
93
|
!!command_instance&.errored?
|
94
94
|
end
|
95
95
|
|
96
|
+
def command_performing?
|
97
|
+
!!command_instance&.performing?
|
98
|
+
end
|
99
|
+
|
96
100
|
def command_performed?
|
97
101
|
!!command_instance&.performed?
|
98
102
|
end
|
@@ -114,6 +118,7 @@ class TurboBoost::Commands::Runner
|
|
114
118
|
return unless command_valid?
|
115
119
|
return if command_aborted?
|
116
120
|
return if command_errored?
|
121
|
+
return if command_performing?
|
117
122
|
return if command_performed?
|
118
123
|
command_instance.perform_with_callbacks command_method_name
|
119
124
|
rescue => error
|
@@ -236,8 +241,7 @@ class TurboBoost::Commands::Runner
|
|
236
241
|
end
|
237
242
|
|
238
243
|
def append_streams_to_response_body
|
239
|
-
|
240
|
-
append_to_response_body command_instance.turbo_streams.map(&:to_s).join.html_safe
|
244
|
+
command_instance.turbo_streams.each { |stream| append_to_response_body stream }
|
241
245
|
end
|
242
246
|
|
243
247
|
def append_meta_tag_to_response_body
|
@@ -267,11 +271,18 @@ class TurboBoost::Commands::Runner
|
|
267
271
|
append_to_response_body event
|
268
272
|
end
|
269
273
|
|
274
|
+
def appended_content
|
275
|
+
@appended_content ||= {}
|
276
|
+
end
|
277
|
+
|
270
278
|
def append_to_response_body(content)
|
271
279
|
return unless controller.response.media_type == "text/html"
|
272
|
-
sanitized_content = content_sanitizer.sanitize(content).html_safe
|
280
|
+
sanitized_content = content_sanitizer.sanitize(content.to_s).html_safe
|
273
281
|
return if sanitized_content.blank?
|
274
282
|
|
283
|
+
return if appended_content[sanitized_content]
|
284
|
+
appended_content[sanitized_content] = true
|
285
|
+
|
275
286
|
html = case response_type
|
276
287
|
when :body
|
277
288
|
match = controller.response.body.match(/<\/\s*body/i).to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_boost-commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hopkins (hopsoft)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0.
|
47
|
+
version: 0.0.7
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.0.
|
54
|
+
version: 0.0.7
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: capybara
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: capybara-playwright-driver
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -422,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
422
422
|
requirements:
|
423
423
|
- - ">="
|
424
424
|
- !ruby/object:Gem::Version
|
425
|
-
version: '
|
425
|
+
version: '2.7'
|
426
426
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
427
427
|
requirements:
|
428
428
|
- - ">="
|