lib/browser/delegate_native.rb in isomorfeus-preact-22.9.0.rc8 vs lib/browser/delegate_native.rb in isomorfeus-preact-22.9.0.rc9
- old
+ new
@@ -22,33 +22,21 @@
def method_missing message, *args, &block
if message.end_with? '='
message = message.chop
property_name = property_for_message(message)
arg = args[0]
- arg = if `arg && typeof arg.$to_n === 'function'`
- arg.to_n
- else
- arg
- end
- return `#@native[#{property_name}] = args[0]`
+ arg = arg.to_n if `arg && typeof arg.$to_n === 'function'`
+ return `#@native[#{property_name}] = arg`
else
property_name = property_for_message(message)
-
%x{
let value = #@native[#{property_name}];
let type = typeof(value);
+ if (type === 'undefined') { return #{super}; }
try {
if (type === 'function') {
- #{
- args.map! do |arg|
- if `arg && typeof arg.$to_n === 'function'`
- arg.to_n
- else
- arg
- end
- end
- }
+ #{args.map! { |arg| `arg && typeof arg.$to_n === 'function'` ? arg.to_n : arg }}
value = value.apply(#@native, args);
}
if (value instanceof HTMLCollection || value instanceof NodeList) {
let a = [];
for(let i=0; i<value.length; i++) {
@@ -67,12 +55,12 @@
}
end
end
def respond_to_missing? message, include_all
- message = message.chop if message.end_with? '='
+ return true if message.end_with? '='
property_name = property_for_message(message)
- return true unless `#{property_name} in #@native`
+ return true if `#{property_name} in #@native`
false
end
def property_for_message(message)
%x{