isomorfeus-preact 22.9.0.rc7 → 22.9.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1444a364c56453f0e45b901f88316ae4262494206149fb63108d206d84fff870
4
- data.tar.gz: d22d8944d3001f1be119335ebaf72d2dac3bfb578b7eb83585ae58b1214171dc
3
+ metadata.gz: 33afa95cb2a08cd3e365b0fe5b602590f43ece313552f760047ed92ccef388b8
4
+ data.tar.gz: 6d23e97bc3af2352863e6b4fc0c8b8bab6ef471cddf1f5a63ce02bfeaf137e3b
5
5
  SHA512:
6
- metadata.gz: 01be4daedd99d8ba24d99125878af8032b0289a806e8eb98584f3bb7848d73fb7157770d30853199747a5ca14497cd9f5de90859006bfb4976e23c4247d68a60
7
- data.tar.gz: 4962e6fb45985477eea0638976e9f600b1f448eedb68a2a9e245e914caefde52c6af0ad1df228b0747a6973bf018582bea1ac62d516c82812cc04d4a3e19abf4
6
+ metadata.gz: 3b4cb524901cf8eaef3832d227874251db99c52ea643c1230903def189b565338e856abecd0a673cb4855fef82f63d955780040565a7f73901dc46175146afca
7
+ data.tar.gz: 66c58db0fa7a4717570b07552da43aa6b89f54e54ce8c461765b7d61014fe482070d8008713bb82ee10dafcb6170f8996903f6a6a2bfd55a7a6e2aae5bb87345
@@ -4,7 +4,6 @@ module Isomorfeus
4
4
  attr_accessor :browser_history
5
5
  attr_accessor :browser_location
6
6
  attr_accessor :current_user_sid_s
7
- attr_accessor :initial_state_fetched
8
7
  attr_accessor :ssr_response_status
9
8
  attr_accessor :top_component
10
9
  attr_reader :initialized
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '22.9.0.rc7'
3
+ VERSION = '22.9.0.rc8'
4
4
  end
5
5
  end
@@ -45,9 +45,22 @@ module Preact::Elements
45
45
  view vkern
46
46
  ]
47
47
 
48
- SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
49
- define_method(element.to_s.underscore.upcase.to_sym) do |props = nil, &block|
50
- Preact._render_element(element, props, &block)
48
+ if RUBY_ENGINE == 'opal'
49
+ SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
50
+ define_method(element.underscore.upcase) do |props = nil, &block|
51
+ %x{
52
+ const op = Opal.Preact;
53
+ const opr = op.render_buffer;
54
+ if (typeof block === 'function') op.$create_element.$$p = block.$to_proc();
55
+ opr[opr.length-1].push(op.$create_element(element, props, nil));
56
+ }
57
+ end
58
+ end
59
+ else
60
+ SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
61
+ define_method(element.to_s.underscore.upcase.to_sym) do |props = nil, &block|
62
+ Preact._render_element(element, props, &block)
63
+ end
51
64
  end
52
65
  end
53
66
 
data/lib/preact.rb CHANGED
@@ -1188,43 +1188,6 @@ module Preact
1188
1188
  end
1189
1189
  end
1190
1190
 
1191
- def create_element(type, props = nil, children = nil, &block)
1192
- if props
1193
- if props.is_a?(Hash)
1194
- normalized_props = props.dup
1195
- key = normalized_props.delete(:key)
1196
- ref = normalized_props.delete(:ref)
1197
- else
1198
- children = props
1199
- normalized_props = {}
1200
- key = nil
1201
- ref = nil
1202
- end
1203
- else
1204
- normalized_props = {}
1205
- key = nil
1206
- ref = nil
1207
- end
1208
-
1209
- if block_given?
1210
- pr = render_buffer
1211
- pr.push([])
1212
- block_result = block.call
1213
- children = pr.pop
1214
- if Preact.is_renderable?(block_result)
1215
- children.push(block_result)
1216
- end
1217
- end
1218
-
1219
- normalized_props[:children] = children unless children.nil?
1220
-
1221
- if RUBY_ENGINE == 'opal'
1222
- `self.createVNode(type, normalized_props, key, ref, null)`
1223
- else
1224
- _create_vnode(type, normalized_props, key, ref, nil)
1225
- end
1226
- end
1227
-
1228
1191
  def create_context(const_name, default_value = nil)
1229
1192
  context = Preact::Context.new(default_value)
1230
1193
  Object.const_set(const_name, context)
@@ -1247,6 +1210,40 @@ module Preact
1247
1210
  attr_accessor :render_buffer
1248
1211
  attr_accessor :rerender_queue
1249
1212
 
1213
+ def create_element(type, props = nil, children = nil, &block)
1214
+ if props
1215
+ if props.is_a?(Hash)
1216
+ normalized_props = props.dup
1217
+ key = normalized_props.delete(:key)
1218
+ ref = normalized_props.delete(:ref)
1219
+ else
1220
+ children = props
1221
+ normalized_props = {}
1222
+ key = nil
1223
+ ref = nil
1224
+ end
1225
+ else
1226
+ normalized_props = {}
1227
+ key = nil
1228
+ ref = nil
1229
+ end
1230
+
1231
+ if block_given?
1232
+ pr = render_buffer
1233
+ pr.JS.push([])
1234
+ block_result = block.call
1235
+ children = pr.JS.pop()
1236
+ if Preact.is_renderable?(block_result)
1237
+ children.JS.push(block_result)
1238
+ end
1239
+ end
1240
+
1241
+ %x{
1242
+ if (children !== nil && children !== null) { #{normalized_props[:children] = children} }
1243
+ return self.createVNode(type, normalized_props, key, ref, null);
1244
+ }
1245
+ end
1246
+
1250
1247
  def _enqueue_render(c)
1251
1248
  if ((`!c._dirty` && (`c._dirty = true`) && rerender_queue.push(c) && `!self.process._rerenderCount++`))
1252
1249
  `setTimeout(self.process)`
@@ -1321,6 +1318,38 @@ module Preact
1321
1318
  VNode.new(type, props, key, ref, original)
1322
1319
  end
1323
1320
 
1321
+ def create_element(type, props = nil, children = nil, &block)
1322
+ if props
1323
+ if props.is_a?(Hash)
1324
+ normalized_props = props.dup
1325
+ key = normalized_props.delete(:key)
1326
+ ref = normalized_props.delete(:ref)
1327
+ else
1328
+ children = props
1329
+ normalized_props = {}
1330
+ key = nil
1331
+ ref = nil
1332
+ end
1333
+ else
1334
+ normalized_props = {}
1335
+ key = nil
1336
+ ref = nil
1337
+ end
1338
+
1339
+ if block_given?
1340
+ pr = render_buffer
1341
+ pr.push([])
1342
+ block_result = block.call
1343
+ children = pr.pop
1344
+ if Preact.is_renderable?(block_result)
1345
+ children.push(block_result)
1346
+ end
1347
+ end
1348
+
1349
+ normalized_props[:children] = children unless children.nil?
1350
+ _create_vnode(type, normalized_props, key, ref, nil)
1351
+ end
1352
+
1324
1353
  def _encode_entities(input)
1325
1354
  s = input.to_s
1326
1355
  return s unless ENCODED_ENTITIES.match?(s)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-preact
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.9.0.rc7
4
+ version: 22.9.0.rc8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 22.9.0.rc7
61
+ version: 22.9.0.rc8
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 22.9.0.rc7
68
+ version: 22.9.0.rc8
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: isomorfeus-redux
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 22.9.0.rc7
75
+ version: 22.9.0.rc8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 22.9.0.rc7
82
+ version: 22.9.0.rc8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: isomorfeus-puppetmaster
85
85
  requirement: !ruby/object:Gem::Requirement