isomorfeus-preact 23.9.0.rc3 → 23.9.0.rc5

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: e407fc877fc823bc4293e77aa42bdfec02301d3c94ab46ab03f64cb1b322ec48
4
- data.tar.gz: ac9a74ed17b3bc6506d2108868b812c72f425b5b5a38331667402172e226e787
3
+ metadata.gz: 6d444d107a9f4342d932c6ee2874ce754c8fe7bffbbdb5dc484a9e068fae3cdd
4
+ data.tar.gz: 53b6ee295e9104a4fcdb57b993641e9f9856a20498f991e4172d0554d1fcdb02
5
5
  SHA512:
6
- metadata.gz: f1a783d3d655b8296ec24c9d402320c7484877b2392cbf5fc095b7b4a3a2e1b240f807febafd2df6c4a7ecf6797420cf44a0622a8759ed471db227967eb1441c
7
- data.tar.gz: 6ec873ec434adb9d2c68c4ff3fd892397b758dde1066fa1fc4c3050c9124763d6c1efd64cba77aa9a2c2bc3032fb6ae7ca87de50edcfd7fa8586d706bae0a3b2
6
+ metadata.gz: 59a632dc3ea15976a62cb50d98b113d0681c6c786fce8806c07a76285454da61e639499556dc0a440ca3f5a7491db64826b9cd2cbed20efa3b5e62bd554f3add
7
+ data.tar.gz: a3dedb4b6551c642584aea4db408c816253a9200e586898d5fa1c356f930fbe6d16d39cd1e9bebab0ffc5a48a2027091f210864911314eac8d843f24aa73bf31
@@ -223,11 +223,6 @@ void internal_render_to_string(VALUE vnode, VALUE context, VALUE is_svg_mode,
223
223
  return;
224
224
  rb_str_buf_append(rres, rb_funcall(self, id_encode_entities, 1, vnode));
225
225
  return;
226
- case T_BIGNUM:
227
- case T_FIXNUM:
228
- case T_FLOAT:
229
- rb_str_buf_append(rres, rb_funcall(vnode, id_to_s, 0));
230
- return;
231
226
  case T_ARRAY:
232
227
  len = RARRAY_LEN(vnode);
233
228
  for (i = 0; i < len; i++) {
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '23.9.0.rc3'
3
+ VERSION = '23.9.0.rc5'
4
4
  end
5
5
  end
data/lib/preact.rb CHANGED
@@ -34,6 +34,40 @@ module Preact
34
34
 
35
35
  if RUBY_ENGINE == 'opal'
36
36
  %x{
37
+ let vnodeId = 0;
38
+
39
+ function vnode_eql(me, other) {
40
+ for(let prop in me) {
41
+ if (prop === 'props' && !(me[prop]["$=="](other[prop]))) {
42
+ return false;
43
+ } else if (me[prop] != other[prop]) {
44
+ return false;
45
+ }
46
+ }
47
+ return true;
48
+ }
49
+
50
+ class VNode {
51
+ constructor(type, props, key, ref, original) {
52
+ this.type = type;
53
+ this.props = props;
54
+ this.key = key;
55
+ this.ref = ref;
56
+ this._children = null;
57
+ this._parent = null;
58
+ this._depth = 0;
59
+ this._dom = null;
60
+ this._nextDom = undefined;
61
+ this._component = null;
62
+ this._hydrating = null;
63
+ this._original = (original == null) ? ++vnodeId : original;
64
+ this.constructor = undefined;
65
+ }
66
+ "$=="(other) { return vnode_eql(this, other); }
67
+ "$eql?"(other) { return vnode_eql(this, other); }
68
+ "$is_a?"(t) { return t === Opal.VNode; }
69
+ }
70
+
37
71
  function _catchError(error, vnode, oldVNode) {
38
72
  let component, ctor, handled;
39
73
 
@@ -63,7 +97,7 @@ module Preact
63
97
  throw error;
64
98
  }
65
99
 
66
- const EMPTY_OBJ = Object.create(null);
100
+ const EMPTY_OBJ = new VNode();
67
101
  const EMPTY_ARR = [];
68
102
  const slice = EMPTY_ARR.slice;
69
103
 
@@ -279,17 +313,17 @@ module Preact
279
313
  // If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,
280
314
  // or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
281
315
  // it's own DOM & etc. pointers
282
- else if (typeof childVNode === 'string' || typeof childVNode === 'number' || typeof childVNode === 'bigint') {
283
- childVNode = newParentVNode._children[i] = self.createVNode(
316
+ else if (typeof childVNode === 'string') {
317
+ childVNode = newParentVNode._children[i] = new VNode(
284
318
  null,
285
319
  childVNode,
286
320
  null,
287
321
  null,
288
322
  childVNode
289
323
  );
290
- } else if (childVNode.$$is_string || childVNode.$$is_number) {
324
+ } else if (childVNode.$$is_string) {
291
325
  let str = childVNode.valueOf();
292
- childVNode = newParentVNode._children[i] = self.createVNode(
326
+ childVNode = newParentVNode._children[i] = new VNode(
293
327
  null,
294
328
  str,
295
329
  null,
@@ -297,7 +331,7 @@ module Preact
297
331
  str
298
332
  );
299
333
  } else if (childVNode.$$is_array) {
300
- childVNode = newParentVNode._children[i] = self.createVNode(
334
+ childVNode = newParentVNode._children[i] = new VNode(
301
335
  Opal.Fragment,
302
336
  #{{ children: `childVNode` }},
303
337
  null,
@@ -309,7 +343,7 @@ module Preact
309
343
  // scenario:
310
344
  // const reuse = <div />
311
345
  // <div>{reuse}<span />{reuse}</div>
312
- childVNode = newParentVNode._children[i] = self.createVNode(
346
+ childVNode = newParentVNode._children[i] = new VNode(
313
347
  childVNode.type,
314
348
  childVNode.props,
315
349
  childVNode.key,
@@ -387,7 +421,7 @@ module Preact
387
421
  }
388
422
 
389
423
  if (
390
- typeof childVNode.type == 'function' &&
424
+ typeof childVNode.type === 'function' &&
391
425
  childVNode._children === oldVNode._children
392
426
  ) {
393
427
  childVNode._nextDom = oldDom = reorderChildren(
@@ -433,7 +467,7 @@ module Preact
433
467
  for (i = oldChildrenLength; i--; ) {
434
468
  if (oldChildren[i] != null) {
435
469
  if (
436
- typeof newParentVNode.type == 'function' &&
470
+ typeof newParentVNode.type === 'function' &&
437
471
  oldChildren[i]._dom != null &&
438
472
  oldChildren[i]._dom == newParentVNode._nextDom
439
473
  ) {
@@ -834,7 +868,7 @@ module Preact
834
868
  validate_props(newType, newProps);
835
869
  newProps.$freeze();
836
870
  }
837
-
871
+
838
872
  if (c["$respond_to?"]("get_derived_state_from_props")) {
839
873
  if (c._nextState == c.state) {
840
874
  c._nextState = c._nextState.$dup();
@@ -987,34 +1021,12 @@ module Preact
987
1021
  });
988
1022
  }
989
1023
 
990
- let vnodeId = 0;
991
1024
 
992
- function is_a_vnode(type) { return type === Opal.VNode; }
993
1025
 
994
1026
  self.createVNode = function(type, props, key, ref, original) {
995
1027
  // V8 seems to be better at detecting type shapes if the object is allocated from the same call site
996
1028
  // Do not inline into createElement and coerceToVNode!
997
- return {
998
- type,
999
- props,
1000
- key,
1001
- ref,
1002
- _children: null,
1003
- _parent: null,
1004
- _depth: 0,
1005
- _dom: null,
1006
- // _nextDom must be initialized to undefined b/c it will eventually
1007
- // be set to dom.nextSibling which can return `null` and it is important
1008
- // to be able to distinguish between an uninitialized _nextDom and
1009
- // a _nextDom that has been set to `null`
1010
- _nextDom: undefined,
1011
- _component: null,
1012
- _hydrating: null,
1013
- constructor: undefined,
1014
- _original: (original == null) ? ++vnodeId : original,
1015
- "$is_a?": is_a_vnode,
1016
- "$$is_vnode": true
1017
- };
1029
+ return new VNode(type, props, key, ref, original);
1018
1030
  }
1019
1031
 
1020
1032
  self.render = function(vnode, parentDom, replaceNode) {
@@ -1083,7 +1095,7 @@ module Preact
1083
1095
 
1084
1096
  if (parentDom) {
1085
1097
  let commitQueue = [];
1086
- const oldVNode = assign({}, vnode);
1098
+ const oldVNode = assign(new VNode(), vnode);
1087
1099
  oldVNode._original = vnode._original + 1;
1088
1100
 
1089
1101
  diff(
@@ -1177,7 +1189,6 @@ module Preact
1177
1189
  end
1178
1190
 
1179
1191
  if RUBY_ENGINE == 'opal'
1180
- attr_accessor :_vnode_id
1181
1192
  attr_accessor :render_buffer
1182
1193
  attr_accessor :rerender_queue
1183
1194
 
@@ -1312,6 +1323,3 @@ module Preact
1312
1323
  end
1313
1324
  end
1314
1325
 
1315
- if RUBY_ENGINE == 'opal'
1316
- Preact._vnode_id = 0
1317
- end
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: 23.9.0.rc3
4
+ version: 23.9.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -78,28 +78,28 @@ dependencies:
78
78
  requirements:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
- version: 23.9.0.rc3
81
+ version: 23.9.0.rc5
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 23.9.0.rc3
88
+ version: 23.9.0.rc5
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: isomorfeus-redux
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 23.9.0.rc3
95
+ version: 23.9.0.rc5
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 23.9.0.rc3
102
+ version: 23.9.0.rc5
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: benchmark-ips
105
105
  requirement: !ruby/object:Gem::Requirement