isomorfeus-preact 10.6.16 → 10.6.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/browser/delegate_native.rb +31 -39
- data/lib/isomorfeus-preact.rb +1 -1
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +2 -1
- data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +2 -1
- data/lib/preact/component/api.rb +1 -1
- data/lib/preact/component/native_component_constructor.rb +2 -1
- data/lib/preact/props.rb +18 -0
- data/lib/preact/state.rb +20 -0
- data/lib/preact/version.rb +1 -1
- data/lib/preact.rb +5 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79141102f4c45c9264382de0ec926a8f9cce4606be4049d8662db3d713184eff
|
4
|
+
data.tar.gz: 3a8b5bcc189fcfcf40c31322ff85c48a9ae71e7d9f0833412429abe3886e06f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2e5b8e8f24cb6e73120e6cdeb03e41cac9747e1758d13b3c928c75292b68b6ceec44912537848a72733befe6652f17798cb451920d206b3bd71d320fce07838
|
7
|
+
data.tar.gz: a179f9b3ed757eabfa1471521858845297df8fe53ac5aba16c9d94c5a7ed058b8fc3b48f42d96b9e2c8fd7506cf99389e649bf901782ce3c21c7a6029cff2e68
|
@@ -16,55 +16,47 @@ module Browser
|
|
16
16
|
# function, that function is invoked with `args`. Otherwise, the property
|
17
17
|
# is returned as is.
|
18
18
|
def method_missing message, *args, &block
|
19
|
-
property_name = property_for_message(message)
|
20
|
-
property = `#@native[#{property_name}]`
|
21
|
-
|
22
|
-
# translate setting a property
|
23
19
|
if message.end_with? '='
|
20
|
+
message = message.chop
|
21
|
+
property_name = property_for_message(message)
|
24
22
|
return `#@native[#{property_name}] = args[0]`
|
25
|
-
end
|
26
|
-
|
27
|
-
# If the native element doesn't have this property, bubble it up
|
28
|
-
super unless `#{property_name} in #@native`
|
29
|
-
|
30
|
-
if `property === false`
|
31
|
-
return false
|
32
|
-
elsif `typeof(property) === 'number' && isNaN(property)`
|
33
|
-
return nil
|
34
23
|
else
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
property_name = property_for_message(message)
|
25
|
+
|
26
|
+
%x{
|
27
|
+
let value = #@native[#{property_name}];
|
28
|
+
let type = typeof(value);
|
29
|
+
if (type === 'function') {
|
30
|
+
return value.apply(#@native, args);
|
31
|
+
} else if (value === null || type === 'undefined' || (type === 'number' && isNaN(value))) {
|
32
|
+
return nil;
|
33
|
+
}
|
34
|
+
return value;
|
35
|
+
}
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
46
39
|
def respond_to_missing? message, include_all
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
message = message.chop if message.end_with? '='
|
41
|
+
property_name = property_for_message(message)
|
42
|
+
return true unless `#{property_name} in #@native`
|
50
43
|
false
|
51
44
|
end
|
52
45
|
|
53
|
-
def property_for_message
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
camel_cased_message
|
46
|
+
def property_for_message(message)
|
47
|
+
%x{
|
48
|
+
let camel_cased_message;
|
49
|
+
if (typeof(#@native[message]) !== 'undefined') { camel_cased_message = message; }
|
50
|
+
else { camel_cased_message = Opal.Preact.lower_camelize(message) }
|
51
|
+
|
52
|
+
if (camel_cased_message.endsWith('?')) {
|
53
|
+
camel_cased_message = camel_cased_message.substring(0, camel_cased_message.length - 2);
|
54
|
+
if (typeof(#@native[camel_cased_message]) === 'undefined') {
|
55
|
+
camel_cased_message = 'is' + camel_cased_message[0].toUpperCase() + camel_cased_message.substring(0, camel_cased_message.length - 1);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
return camel_cased_message
|
59
|
+
}
|
68
60
|
end
|
69
61
|
end
|
70
62
|
end
|
data/lib/isomorfeus-preact.rb
CHANGED
@@ -33,9 +33,10 @@ module LucidApp
|
|
33
33
|
var defined_refs = #{base.defined_refs};
|
34
34
|
for (var ref in defined_refs) {
|
35
35
|
if (defined_refs[ref] != null) {
|
36
|
+
let r = ref; // to ensure cloure for function below gets correct ref name
|
36
37
|
this[ref] = function(element) {
|
37
38
|
element = oper.native_element_or_component_to_ruby(element);
|
38
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[
|
39
|
+
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
39
40
|
}
|
40
41
|
this[ref] = this[ref].bind(this);
|
41
42
|
} else {
|
@@ -29,9 +29,10 @@ module LucidComponent
|
|
29
29
|
var defined_refs = base.$defined_refs();
|
30
30
|
for (var ref in defined_refs) {
|
31
31
|
if (defined_refs[ref] != null) {
|
32
|
+
let r = ref; // to ensure cloure for function below gets correct ref name
|
32
33
|
this[ref] = function(element) {
|
33
34
|
element = oper.native_element_or_component_to_ruby(element);
|
34
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[
|
35
|
+
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
35
36
|
}
|
36
37
|
this[ref] = this[ref].bind(this);
|
37
38
|
} else {
|
data/lib/preact/component/api.rb
CHANGED
@@ -19,9 +19,10 @@ module Preact
|
|
19
19
|
var defined_refs = #{base.defined_refs};
|
20
20
|
for (var ref in defined_refs) {
|
21
21
|
if (defined_refs[ref] != null) {
|
22
|
+
let r = ref; // to ensure cloure for function below gets correct ref name
|
22
23
|
this[ref] = function(element) {
|
23
24
|
element = Opal.Preact.native_element_or_component_to_ruby(element);
|
24
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[
|
25
|
+
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
25
26
|
}
|
26
27
|
this[ref] = this[ref].bind(this);
|
27
28
|
} else {
|
data/lib/preact/props.rb
CHANGED
@@ -11,6 +11,24 @@ module Preact
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
|
+
def [](prop)
|
15
|
+
%x{
|
16
|
+
const p = #@native.props;
|
17
|
+
if (typeof p[prop] === 'undefined') {
|
18
|
+
prop = Opal.Preact.lower_camelize(prop);
|
19
|
+
if (typeof p[prop] === 'undefined') { return nil; }
|
20
|
+
}
|
21
|
+
return p[prop];
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def key?(k)
|
26
|
+
%x{
|
27
|
+
if (typeof #@native.props[k] !== 'undefined') { return true; }
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
14
32
|
def method_missing(prop, *args, &block)
|
15
33
|
%x{
|
16
34
|
const p = #@native.props;
|
data/lib/preact/state.rb
CHANGED
@@ -13,6 +13,26 @@ module Preact
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
+
def [](key)
|
17
|
+
%x{
|
18
|
+
if (typeof #@native.state[key] === 'undefined') { return nil; }
|
19
|
+
return #@native.state[key];
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def []=(key)
|
24
|
+
new_state = `{}`
|
25
|
+
new_state.JS[(`key.endsWith('=')` ? key.chop : key)] = args[0]
|
26
|
+
@native.JS.setState(new_state, `null`)
|
27
|
+
end
|
28
|
+
|
29
|
+
def key?(k)
|
30
|
+
%x{
|
31
|
+
if (typeof #@native.state[k] !== 'undefined') { return true; }
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
16
36
|
def method_missing(key, *args, &block)
|
17
37
|
if `args.length > 0`
|
18
38
|
new_state = `{}`
|
data/lib/preact/version.rb
CHANGED
data/lib/preact.rb
CHANGED
@@ -57,8 +57,9 @@ module Preact
|
|
57
57
|
};
|
58
58
|
|
59
59
|
self.native_element_or_component_to_ruby = function (element) {
|
60
|
-
if (typeof
|
61
|
-
if (
|
60
|
+
if (element == null || typeof(element) === 'undefined' ) { return nil; }
|
61
|
+
if (typeof element.__ruby_instance !== 'undefined') { return element.__ruby_instance; }
|
62
|
+
if (element instanceof Element || element instanceof Node) { return #{Browser::Element.new(`element`)}; }
|
62
63
|
return element;
|
63
64
|
};
|
64
65
|
|
@@ -169,6 +170,8 @@ module Preact
|
|
169
170
|
else { component_name = active_component.$to_s(); }
|
170
171
|
#{Isomorfeus.raise_error(message: "Is #{`value`} a valid method of #{`component_name`}? If so then please use: #{`key`}: method_ref(:#{`value`}) within component: #{`component_name`}")}
|
171
172
|
}
|
173
|
+
} else if (type === "object" && value === nil) {
|
174
|
+
result[self.lower_camelize(key)] = null;
|
172
175
|
} else {
|
173
176
|
let active_component = self.active_component();
|
174
177
|
let component_name;
|
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: 10.6.
|
4
|
+
version: 10.6.20
|
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-01-
|
11
|
+
date: 2022-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.14.
|
89
|
+
version: 0.14.7
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.14.
|
96
|
+
version: 0.14.7
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-redux
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|