isomorfeus-preact 23.1.0.rc1 → 23.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,25 @@
1
1
  #include <ruby.h>
2
+ #undef DEPRECATED
2
3
  #define FIO_MEMORY_NAME vnode
3
4
  #include "fio-stl.h"
4
- #include "isomorfeus_preact_ext.h"
5
+ #include "vnode.h"
5
6
 
6
7
  VALUE cVNode;
7
8
 
8
9
  static void preact_vnode_mark(void *p) {
9
- VNode *v = (VNode *)p;
10
- rb_gc_mark(v->component);
11
- rb_gc_mark(v->key);
12
- rb_gc_mark(v->props);
13
- rb_gc_mark(v->ref);
14
- rb_gc_mark(v->type);
10
+ VNode *v = (VNode *)p;
11
+ rb_gc_mark(v->component);
12
+ rb_gc_mark(v->key);
13
+ rb_gc_mark(v->props);
14
+ rb_gc_mark(v->ref);
15
+ rb_gc_mark(v->type);
15
16
  }
16
17
 
17
- static void preact_vnode_free(void *p) {
18
- vnode_free(p);
18
+ VNode *vnode_emalloc(void) {
19
+ VNode *v = vnode_malloc(sizeof(VNode));
20
+ if (v == NULL)
21
+ rb_raise(rb_eNoMemError, "failed allocation of VNode");
22
+ return v;
19
23
  }
20
24
 
21
25
  static size_t preact_vnode_size(const void *p) {
@@ -23,26 +27,23 @@ static size_t preact_vnode_size(const void *p) {
23
27
  (void)p;
24
28
  }
25
29
 
26
- const rb_data_type_t preact_vnode_t = {
27
- .wrap_struct_name = "VNode",
28
- .function = {
29
- .dmark = preact_vnode_mark,
30
- .dfree = preact_vnode_free,
31
- .dsize = preact_vnode_size,
32
- .dcompact = NULL,
33
- .reserved = {0}
34
- },
35
- .parent = NULL,
36
- .data = NULL,
37
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
38
- };
30
+ const rb_data_type_t preact_vnode_t = {.wrap_struct_name = "VNode",
31
+ .function = {.dmark = preact_vnode_mark,
32
+ .dfree = vnode_free,
33
+ .dsize = preact_vnode_size,
34
+ .dcompact = NULL,
35
+ .reserved = {0}},
36
+ .parent = NULL,
37
+ .data = NULL,
38
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
39
39
 
40
40
  static VALUE preact_vnode_alloc(VALUE rclass) {
41
- void *v = vnode_malloc(sizeof(VNode));
42
- return TypedData_Wrap_Struct(rclass, &preact_vnode_t, v);
41
+ return TypedData_Wrap_Struct(rclass, &preact_vnode_t,
42
+ vnode_emalloc());
43
43
  }
44
44
 
45
- static VALUE preact_vnode_init(VALUE self, VALUE type, VALUE props, VALUE key, VALUE ref) {
45
+ static VALUE preact_vnode_init(VALUE self, VALUE type, VALUE props, VALUE key,
46
+ VALUE ref) {
46
47
  VNode *v = (VNode *)DATA_PTR(self);
47
48
  v->component = Qnil;
48
49
  v->key = key;
@@ -53,9 +54,7 @@ static VALUE preact_vnode_init(VALUE self, VALUE type, VALUE props, VALUE key, V
53
54
  }
54
55
 
55
56
  static VALUE preact_vnode_set_c(VALUE self, VALUE c) {
56
- VNode *v = (VNode *)DATA_PTR(self);
57
- v->component = c;
58
- return c;
57
+ return ((VNode *)DATA_PTR(self))->component = c;
59
58
  }
60
59
 
61
60
  static VALUE preact_vnode_get_c(VALUE self) {
@@ -0,0 +1,9 @@
1
+ #include <ruby.h>
2
+
3
+ typedef struct VNode {
4
+ VALUE component;
5
+ VALUE key;
6
+ VALUE props;
7
+ VALUE ref;
8
+ VALUE type;
9
+ } VNode;
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '23.1.0.rc1'
3
+ VERSION = '23.6.0.rc1'
4
4
  end
5
5
  end
@@ -1,169 +1,169 @@
1
- module Isomorfeus
2
- module Props
3
- class Validator
4
- def initialize(source_class, prop, value, options)
5
- @c = source_class
6
- @p = prop
7
- @v = value
8
- @o = options
9
- end
10
-
11
- def validate!
12
- ensured = ensure!
13
- unless ensured
14
- set_default_value
15
- cast!
16
- type!
17
- end
18
- run_checks!
19
- true
20
- end
21
-
22
- def validated_value
23
- validate!
24
- @v
25
- end
26
-
27
- private
28
-
29
- # basic tests
30
-
31
- def set_default_value
32
- return unless @v.nil?
33
- @v = @o[:default] if @o.key?(:default)
34
- end
35
-
36
- def cast!
37
- if @o.key?(:cast)
38
- begin
39
- return if @o[:is_a] && @v.is_a?(@o[:is_a])
40
- return if @o[:class] && @v.class == @o[:class]
41
- if @o[:type] == :boolean
42
- @v = !!@v
43
- return
44
- end
45
- cl = @o[:is_a] || @o[:class]
46
- @v = case cl.name
47
- when 'Integer' then @v.to_i
48
- when 'String' then @v.to_s
49
- when 'Float' then @v.to_f
50
- when 'Array' then @v.to_a
51
- when 'Hash' then @v.to_h
52
- else
53
- Isomorfeus.raise_error(message: "#{@c}: Dont know how to cast #{@p} to #{cl}!")
54
- end
55
- rescue
56
- Isomorfeus.raise_error(message: "#{@c}: #{@p} cast to #{cl} failed!")
57
- end
58
- end
59
- end
60
-
61
- def ensure!
62
- if @o.key?(:ensure)
63
- proc_or_val = @o[:ensure]
64
- if proc_or_val.class == Proc
65
- @v = proc_or_val.call(@v)
66
- else
67
- @v = proc_or_val
68
- end
69
- true
70
- else
71
- false
72
- end
73
- end
74
-
75
- def type!
76
- return if @o[:allow_nil] && @v.nil?
77
- if @o.key?(:class)
78
- Isomorfeus.raise_error(message: "#{@c}: #{@p} class is not #{@o[:class]}") unless @v.class == @o[:class]
79
- elsif @o.key?(:is_a)
80
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a #{@o[:is_a]}") unless @v.is_a?(@o[:is_a])
81
- elsif @o.key?(:type)
82
- case @o[:type]
83
- when :boolean
84
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a boolean") unless @v.class == TrueClass || @v.class == FalseClass
85
- else
86
- c_string_sub_types
87
- end
88
- end
89
- end
90
-
91
- # all other checks
92
-
93
- def run_checks!
94
- if @o.key?(:validate)
95
- @o[:validate].each do |m, l|
96
- send('c_' + m, l)
97
- end
98
- end
99
- @o[:validate_block].call(@v) if @o.key?(:validate_block)
100
- end
101
-
102
- # specific validations
103
- def c_gt(v)
104
- Isomorfeus.raise_error(message: "#{@c}: #{@p} not greater than #{v}!") unless @v > v
105
- end
106
-
107
- def c_lt(v)
108
- Isomorfeus.raise_error(message: "#{@c}: #{@p} not less than #{v}!") unless @v < v
109
- end
110
-
111
- def c_keys(v)
112
- Isomorfeus.raise_error(message: "#{@c}: #{@p} keys dont fit!") unless @v.keys.sort == v.sort
113
- end
114
-
115
- def c_size(v)
116
- Isomorfeus.raise_error(message: "#{@c}: #{@p} length/size is not #{v}") unless @v.length == v
117
- end
118
-
119
- def c_matches(v)
120
- Isomorfeus.raise_error(message: "#{@c}: #{@p} does not match #{v}") unless v.match?(@v)
121
- end
122
-
123
- def c_max(v)
124
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is larger than #{v}") unless @v <= v
125
- end
126
-
127
- def c_min(v)
128
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is smaller than #{v}") unless @v >= v
129
- end
130
-
131
- def c_max_size(v)
132
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is larger than #{v}") unless @v.length <= v
133
- end
134
-
135
- def c_min_size(v)
136
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is smaller than #{v}") unless @v.length >= v
137
- end
138
-
139
- def c_direction(v)
140
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is positive") if v == :negative && @v >= 0
141
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is negative") if v == :positive && @v < 0
142
- end
143
-
144
- def c_test
145
- Isomorfeus.raise_error(message: "#{@c}: #{@p} test condition check failed") unless @o[:test].call(@v)
146
- end
147
-
148
- def c_string_sub_types
149
- Isomorfeus.raise_error(message: "#{@c}: #{@p} must be a String") unless @v.class == String
150
- case @o[:type]
151
- when :email
152
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid email address") unless @v.match?(/\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/)
153
- when :uri
154
- if RUBY_ENGINE == 'opal'
155
- %x{
156
- try {
157
- new URL(#@v);
158
- } catch {
159
- #{Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri")}
160
- }
161
- }
162
- else
163
- Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri") unless @v.match?(/\A#{URI.regexp}\z/)
164
- end
165
- end
166
- end
167
- end
168
- end
169
- end
1
+ module Isomorfeus
2
+ module Props
3
+ class Validator
4
+ def initialize(source_class, prop, value, options)
5
+ @c = source_class
6
+ @p = prop
7
+ @v = value
8
+ @o = options
9
+ end
10
+
11
+ def validate!
12
+ ensured = ensure!
13
+ unless ensured
14
+ set_default_value
15
+ cast!
16
+ type!
17
+ end
18
+ run_checks!
19
+ true
20
+ end
21
+
22
+ def validated_value
23
+ validate!
24
+ @v
25
+ end
26
+
27
+ private
28
+
29
+ # basic tests
30
+
31
+ def set_default_value
32
+ return unless @v.nil?
33
+ @v = @o[:default] if @o.key?(:default)
34
+ end
35
+
36
+ def cast!
37
+ if @o.key?(:cast)
38
+ begin
39
+ return if @o[:is_a] && @v.is_a?(@o[:is_a])
40
+ return if @o[:class] && @v.class == @o[:class]
41
+ if @o[:type] == :boolean
42
+ @v = !!@v
43
+ return
44
+ end
45
+ cl = @o[:is_a] || @o[:class]
46
+ @v = case cl.name
47
+ when 'Integer' then @v.to_i
48
+ when 'String' then @v.to_s
49
+ when 'Float' then @v.to_f
50
+ when 'Array' then @v.to_a
51
+ when 'Hash' then @v.to_h
52
+ else
53
+ Isomorfeus.raise_error(message: "#{@c}: Dont know how to cast #{@p} to #{cl}!")
54
+ end
55
+ rescue
56
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} cast to #{cl} failed!")
57
+ end
58
+ end
59
+ end
60
+
61
+ def ensure!
62
+ if @o.key?(:ensure)
63
+ proc_or_val = @o[:ensure]
64
+ if proc_or_val.class == Proc
65
+ @v = proc_or_val.call(@v)
66
+ else
67
+ @v = proc_or_val
68
+ end
69
+ true
70
+ else
71
+ false
72
+ end
73
+ end
74
+
75
+ def type!
76
+ return if @o[:allow_nil] && @v.nil?
77
+ if @o.key?(:class)
78
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} class is not #{@o[:class]}") unless @v.class == @o[:class]
79
+ elsif @o.key?(:is_a)
80
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a #{@o[:is_a]}") unless @v.is_a?(@o[:is_a])
81
+ elsif @o.key?(:type)
82
+ case @o[:type]
83
+ when :boolean
84
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a boolean") unless @v.class == TrueClass || @v.class == FalseClass
85
+ else
86
+ c_string_sub_types
87
+ end
88
+ end
89
+ end
90
+
91
+ # all other checks
92
+
93
+ def run_checks!
94
+ if @o.key?(:validate)
95
+ @o[:validate].each do |m, l|
96
+ send('c_' + m, l)
97
+ end
98
+ end
99
+ @o[:validate_block].call(@v) if @o.key?(:validate_block)
100
+ end
101
+
102
+ # specific validations
103
+ def c_gt(v)
104
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} not greater than #{v}!") unless @v > v
105
+ end
106
+
107
+ def c_lt(v)
108
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} not less than #{v}!") unless @v < v
109
+ end
110
+
111
+ def c_keys(v)
112
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} keys dont fit!") unless @v.keys.sort == v.sort
113
+ end
114
+
115
+ def c_size(v)
116
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} length/size is not #{v}") unless @v.length == v
117
+ end
118
+
119
+ def c_matches(v)
120
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} does not match #{v}") unless v.match?(@v)
121
+ end
122
+
123
+ def c_max(v)
124
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is larger than #{v}") unless @v <= v
125
+ end
126
+
127
+ def c_min(v)
128
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is smaller than #{v}") unless @v >= v
129
+ end
130
+
131
+ def c_max_size(v)
132
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is larger than #{v}") unless @v.length <= v
133
+ end
134
+
135
+ def c_min_size(v)
136
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is smaller than #{v}") unless @v.length >= v
137
+ end
138
+
139
+ def c_direction(v)
140
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is positive") if v == :negative && @v >= 0
141
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is negative") if v == :positive && @v < 0
142
+ end
143
+
144
+ def c_test
145
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} test condition check failed") unless @o[:test].call(@v)
146
+ end
147
+
148
+ def c_string_sub_types
149
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} must be a String") unless @v.class == String
150
+ case @o[:type]
151
+ when :email
152
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid email address") unless @v.match?(/\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/)
153
+ when :uri
154
+ if RUBY_ENGINE == 'opal'
155
+ %x{
156
+ try {
157
+ new URL(#@v);
158
+ } catch {
159
+ #{Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri")}
160
+ }
161
+ }
162
+ else
163
+ Isomorfeus.raise_error(message: "#{@c}: #{@p} is not a valid uri") unless @v.match?(/\A#{URI.regexp}\z/)
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
data/lib/preact.rb CHANGED
@@ -53,6 +53,7 @@ module Preact
53
53
  const EMPTY_OBJ = {};
54
54
  const EMPTY_ARR = [];
55
55
  const slice = EMPTY_ARR.slice;
56
+ const isArray = Array.isArray;
56
57
 
57
58
  function assign(obj, props) {
58
59
  for (let i in props) obj[i] = props[i];
@@ -278,7 +279,7 @@ module Preact
278
279
  null,
279
280
  str
280
281
  );
281
- } else if (Array.isArray(childVNode)) {
282
+ } else if (isArray(childVNode)) {
282
283
  childVNode = newParentVNode._children[i] = self.createVNode(
283
284
  Opal.Fragment,
284
285
  #{{ children: `childVNode` }},
@@ -438,11 +439,11 @@ module Preact
438
439
  }
439
440
 
440
441
  function eventProxy(e) {
441
- this._listeners[e.type + false].$call(#{Browser::Event.new(`e`)});
442
+ this._listeners[e.type + false].$call(#{::Browser::Event.new(`e`)});
442
443
  }
443
444
 
444
445
  function eventProxyCapture(e) {
445
- this._listeners[e.type + true].$call(#{Browser::Event.new(`e`)});
446
+ this._listeners[e.type + true].$call(#{::Browser::Event.new(`e`)});
446
447
  }
447
448
 
448
449
  const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
@@ -533,6 +534,8 @@ module Preact
533
534
  // cast to `0` instead
534
535
  name !== 'tabIndex' &&
535
536
  name !== 'download' &&
537
+ name !== 'rowSpan' &&
538
+ name !== 'colSpan' &&
536
539
  name in dom
537
540
  ) {
538
541
  try {
@@ -542,18 +545,18 @@ module Preact
542
545
  } catch (e) {}
543
546
  }
544
547
 
545
- // ARIA-attributes have a different notion of boolean values.
546
- // The value `false` is different from the attribute not
547
- // existing on the DOM, so we can't remove it. For non-boolean
548
- // ARIA-attributes we could treat false as a removal, but the
549
- // amount of exceptions would cost us too many bytes. On top of
550
- // that other VDOM frameworks also always stringify `false`.
548
+ // aria- and data- attributes have no boolean representation.
549
+ // A `false` value is different from the attribute not being
550
+ // present, so we can't remove it. For non-boolean aria
551
+ // attributes we could treat false as a removal, but the
552
+ // amount of exceptions would cost too many bytes. On top of
553
+ // that other frameworks generally stringify `false`.
551
554
 
552
555
  if (typeof value === 'function') {
553
556
  // never serialize functions as attribute values
554
557
  } else if (
555
558
  value != null && value !== nil &&
556
- (value !== false || (name[0] === 'a' && name[1] === 'r'))
559
+ (value !== false || (name[4] === '-'))
557
560
  ) {
558
561
  dom.setAttribute(name, value);
559
562
  } else {
@@ -688,7 +691,7 @@ module Preact
688
691
  i = newVNode.props["$[]"]("children");
689
692
  diffChildren(
690
693
  dom,
691
- Array.isArray(i) ? i : [i],
694
+ isArray(i) ? i : [i],
692
695
  newVNode,
693
696
  oldVNode,
694
697
  globalContext,
@@ -895,7 +898,7 @@ module Preact
895
898
 
896
899
  diffChildren(
897
900
  parentDom,
898
- Array.isArray(renderResult) ? renderResult : [renderResult],
901
+ isArray(renderResult) ? renderResult : [renderResult],
899
902
  newVNode,
900
903
  oldVNode,
901
904
  globalContext,
@@ -970,7 +973,7 @@ module Preact
970
973
  }
971
974
 
972
975
  let vnodeId = 0;
973
- const vnode_class = #{VNode};
976
+ const vnode_class = #{::VNode};
974
977
 
975
978
  function is_a_vnode(type) { return type === vnode_class; }
976
979
  function is_nil() { return false; }
@@ -1116,9 +1119,10 @@ module Preact
1116
1119
  self.process._rerenderCount = 0;
1117
1120
  }
1118
1121
  else
1119
- IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i
1122
+ IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i.freeze
1120
1123
  JS_TO_CSS = {}
1121
- ENCODED_ENTITIES = /[&<>"]/
1124
+ ENCODED_ENTITIES = /[&<>"]/.freeze
1125
+ ENTITY_REPLACEMENTS = { '&'.freeze => '&amp;'.freeze, '<'.freeze => '&lt;'.freeze, '>'.freeze => '&gt;'.freeze, '"'.freeze => '&quot;'.freeze }.freeze
1122
1126
  end
1123
1127
 
1124
1128
  class << self
@@ -1156,19 +1160,19 @@ module Preact
1156
1160
  if RUBY_ENGINE == 'opal'
1157
1161
  `self.createVNode(vnode.type, normalized_props, #{key || `vnode.key`}, #{ref || `vnode.ref`}, null)`
1158
1162
  else
1159
- VNode.new(vnode.type, normalized_props, key || vnode.key, ref || vnode.ref)
1163
+ ::VNode.new(vnode.type, normalized_props, key || vnode.key, ref || vnode.ref)
1160
1164
  end
1161
1165
  end
1162
1166
 
1163
1167
  def create_context(const_name, default_value = nil)
1164
- context = Preact::Context.new(default_value)
1165
- Object.const_set(const_name, context)
1168
+ context = ::Preact::Context.new(default_value)
1169
+ ::Object.const_set(const_name, context)
1166
1170
  end
1167
1171
 
1168
1172
  def _init_render
1169
1173
  self.render_buffer = []
1170
1174
  self.rerender_queue = []
1171
- Isomorfeus.reset_something_loading
1175
+ ::Isomorfeus.reset_something_loading
1172
1176
  end
1173
1177
 
1174
1178
  if RUBY_ENGINE == 'opal'
@@ -1244,7 +1248,7 @@ module Preact
1244
1248
  return `document.body.querySelector(element_or_query)`
1245
1249
  elsif `(typeof element_or_query === 'function')`
1246
1250
  return element_or_query
1247
- elsif element_or_query.is_a?(Browser::Element)
1251
+ elsif element_or_query.is_a?(::Browser::Element)
1248
1252
  return element_or_query.to_n
1249
1253
  else
1250
1254
  return element_or_query
@@ -1264,44 +1268,24 @@ module Preact
1264
1268
  end
1265
1269
  else # RUBY_ENGINE
1266
1270
  def render_buffer
1267
- Thread.current[:@_isomorfeus_preact_render_buffer]
1271
+ ::Thread.current[:@_isomorfeus_preact_render_buffer]
1268
1272
  end
1269
1273
 
1270
1274
  def render_buffer=(i)
1271
- Thread.current[:@_isomorfeus_preact_render_buffer] = i
1275
+ ::Thread.current[:@_isomorfeus_preact_render_buffer] = i
1272
1276
  end
1273
1277
 
1274
1278
  def rerender_queue
1275
- Thread.current[:@_isomorfeus_preact_rerender_queue]
1279
+ ::Thread.current[:@_isomorfeus_preact_rerender_queue]
1276
1280
  end
1277
1281
 
1278
1282
  def rerender_queue=(i)
1279
- Thread.current[:@_isomorfeus_preact_rerender_queue] = i
1280
- end
1281
-
1282
- def is_renderable?(block_result)
1283
- block_result &&
1284
- (block_result.is_a?(VNode) || block_result.is_a?(String) || block_result.is_a?(Numeric) ||
1285
- (block_result.is_a?(Array) && block_result.length > 0 && is_renderable?(block_result[0])))
1283
+ ::Thread.current[:@_isomorfeus_preact_rerender_queue] = i
1286
1284
  end
1287
1285
 
1288
1286
  def _encode_entities(input)
1289
- s = input.to_s
1290
- return s unless ENCODED_ENTITIES.match?(s)
1291
- # TODO performance maybe, maybe similar to new js way, need to measure
1292
- # for (; i<str.length; i++) {
1293
- # switch (str.charCodeAt(i)) {
1294
- # case 60: ch = '&lt;'; break;
1295
- # case 62: ch = '&gt;'; break;
1296
- # case 34: ch = '&quot;'; break;
1297
- # case 38: ch = '&amp;'; break;
1298
- # default: continue;
1299
- # }
1300
- # if (i > start) out += str.slice(start, i);
1301
- # out += ch;
1302
- # start = i + 1;
1303
- # }
1304
- s.gsub(/&/, '&amp;').gsub(/</, '&lt;').gsub(/>/, '&gt;').gsub(/"/, '&quot;')
1287
+ return input unless input.match?(ENCODED_ENTITIES)
1288
+ input.gsub(ENCODED_ENTITIES, ENTITY_REPLACEMENTS)
1305
1289
  end
1306
1290
 
1307
1291
  def _style_obj_to_css(v)
@@ -1320,16 +1304,9 @@ module Preact
1320
1304
  return str.empty? ? nil : str
1321
1305
  end
1322
1306
 
1323
- def _render_element(element, props, &block)
1324
- pr = Preact.render_buffer
1325
- pr[pr.length-1] << create_element(element, props, nil, &block)
1326
- nil
1327
- end
1328
-
1329
1307
  def render_to_string(vnode, context = nil)
1330
1308
  _init_render
1331
- context = {} unless context
1332
- _render_to_string(vnode, context, false, nil)
1309
+ _render_to_string(vnode, context)
1333
1310
  end
1334
1311
  end # RUBY_ENGINE
1335
1312
  end