glib-web 5.0.2 → 5.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50fd58d6fa3b0ee4d505c72f4bc49adf0809e208486eeb5c0aaeada10d39dfa
4
- data.tar.gz: f32fb5c6985560a68a6240586e2a6411ffaec55dab2a30c12eecc177a002efaa
3
+ metadata.gz: 4f8b29b4f537ee6bf84d38fb8e0e9731b66a6f7dd39cc7498d2dc38680b47832
4
+ data.tar.gz: e6b063e4098ef285461c961c166ce3bb18f54749b20e83a27ccea15480f37c43
5
5
  SHA512:
6
- metadata.gz: 0ddfb285130294449bbb45b56458dedfaa5cdc7ad791877b8e7e722e4da26bf0cfa2c11b5b24a56031d2da80bcdac40a6065bee6c453add16891f91956f81cca
7
- data.tar.gz: 3f5ed1fc1745800c005db0356d123b6e334d6333262e99943933ee528861227cb31174618bd9d400c73eb8b849906a534bc47018bbe0eeb5472cc5efc323325f
6
+ metadata.gz: 68b869bf225f42361ee6e2aa10004101469ed51298961dd5acd86a33305c6a475a864788071e44d2d1fc6fa6253a0d198279936052ccb127a4d74b4bbf6cf164
7
+ data.tar.gz: c7204c91732b75735519b7242ee04d481ef11a938f0194963f3eaeb21b2c8e3d65c45e29c1b7a45398440eb4475126dfcf51397ff09e5a725d12b7714c28ea4f
@@ -286,15 +286,12 @@ module Glib
286
286
  def self.action(propName)
287
287
  define_method(propName) do |value|
288
288
  if value # Allow nil value
289
+ # Isolate nested action callbacks (e.g. onClick) from the outer context's
290
+ # singleton-tracking state, and ensure the outer state is restored even if
291
+ # the callback raises.
289
292
  json.set!(propName) do
290
- # Save/restore singleton tracking around nested action callbacks (e.g. onClick)
291
- # to prevent the inner callback from polluting the outer context's state.
292
- builder = page.action_builder
293
- saved_singleton_set = builder.singleton_action_set
294
- saved_singleton_name = builder.singleton_action_name
295
- builder.reset_singleton_tracking!
296
- value.call(builder)
297
- builder.restore_singleton_tracking!(saved_singleton_set, saved_singleton_name)
293
+ action_builder = page.action_builder
294
+ action_builder.with_isolated_singleton_tracking { value.call(action_builder) }
298
295
  end
299
296
  end
300
297
  end
@@ -19,6 +19,21 @@ module Glib
19
19
  @singleton_action_name = action_name
20
20
  end
21
21
 
22
+ # Runs block with fresh singleton-tracking state, then restores whatever
23
+ # was there before — even if the block raises. Used around user-provided
24
+ # callbacks (onLoad, onUnload, etc.) so that their action state doesn't
25
+ # leak out and trip the singleton guard on later actions.
26
+ def with_isolated_singleton_tracking
27
+ saved_set = @singleton_action_set
28
+ saved_name = @singleton_action_name
29
+ reset_singleton_tracking!
30
+ begin
31
+ yield
32
+ ensure
33
+ restore_singleton_tracking!(saved_set, saved_name)
34
+ end
35
+ end
36
+
22
37
  def method_missing(m, *args)
23
38
  if @multiple
24
39
  add_element_to_array_v1 'action', m, *args
@@ -76,6 +76,11 @@ module Glib
76
76
 
77
77
  def json_ui_action(json)
78
78
  @__json_ui_action ||= Page.new(json, self)
79
+ # The Page is memoized across calls within the same view context (e.g. sequential
80
+ # injection templates sharing one render). Reset the builder's singleton-tracking
81
+ # state so each caller gets a fresh state, otherwise a prior caller's action
82
+ # would trip the singleton guard.
83
+ @__json_ui_action.action_builder.reset_singleton_tracking!
79
84
  @__json_ui_action.action_builder
80
85
  end
81
86
 
@@ -135,19 +140,19 @@ module Glib
135
140
  json.actionCable do
136
141
  if (on_error = options[:onError])
137
142
  json.onError do
138
- on_error.call(@action_builder)
143
+ @action_builder.with_isolated_singleton_tracking { on_error.call(@action_builder) }
139
144
  end
140
145
  end
141
146
 
142
147
  if (on_open = options[:onOpen])
143
148
  json.onOpen do
144
- on_open.call(@action_builder)
149
+ @action_builder.with_isolated_singleton_tracking { on_open.call(@action_builder) }
145
150
  end
146
151
  end
147
152
 
148
153
  if (on_close = options[:onClose])
149
154
  json.onClose do
150
- on_close.call(@action_builder)
155
+ @action_builder.with_isolated_singleton_tracking { on_close.call(@action_builder) }
151
156
  end
152
157
  end
153
158
 
@@ -298,31 +303,31 @@ module Glib
298
303
  def on(options = {})
299
304
  if (on_load = options[:load])
300
305
  json.onLoad do
301
- on_load.call @action_builder
306
+ @action_builder.with_isolated_singleton_tracking { on_load.call @action_builder }
302
307
  end
303
308
  end
304
309
 
305
310
  if (on_rerender = options[:reRender])
306
311
  json.onRerender do
307
- on_rerender.call @action_builder
312
+ @action_builder.with_isolated_singleton_tracking { on_rerender.call @action_builder }
308
313
  end
309
314
  end
310
315
 
311
316
  if (on_unload = options[:unload])
312
317
  json.onUnload do
313
- on_unload.call @action_builder
318
+ @action_builder.with_isolated_singleton_tracking { on_unload.call @action_builder }
314
319
  end
315
320
  end
316
321
 
317
322
  if (on_refocus = options[:refocus])
318
323
  json.onRefocus do
319
- on_refocus.call @action_builder
324
+ @action_builder.with_isolated_singleton_tracking { on_refocus.call @action_builder }
320
325
  end
321
326
  end
322
327
 
323
328
  if (on_foreground = options[:foreground])
324
329
  json.onForeground do
325
- on_foreground.call @action_builder
330
+ @action_builder.with_isolated_singleton_tracking { on_foreground.call @action_builder }
326
331
  end
327
332
  end
328
333
  end
data/lib/tasks/db.rake CHANGED
@@ -64,7 +64,6 @@ namespace :db do
64
64
  entries.each do |a|
65
65
  attrs = Hash[a.attributes.sort]
66
66
  attrs.delete_if { |k, v| v.nil? }
67
- # attrs.delete_if { |k, v| v.nil? }
68
67
 
69
68
  id = if attrs.include?('id')
70
69
  [a.id]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''