-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shouldn't Element be a Native? #24
Comments
Yes, it should. But there are problems we need to address first. The main one is the type of object to return from native calls (via Sure, we could just use a plain wrapper for We could introduce properties to natives to say what classes they could become. e.g., we could add something like this to $.fn.toOpal = function() {
return Opal.Element.$new(this);
}; And Just a thought. |
As an example: class Native
def method_missing(*)
%x{
// all logic here
if (typeof (result.toOpal) === "function") {
return result.toOpal();
}
return #{ Native(`result`) };
}
end
end |
As @meh suggests, perhaps |
I tried patching I relied a lot on this feature for jquery plugins. |
Can you show me the code for the |
I tried patching class Element
# Missing methods are assumed to be jquery plugins. These are called by
# the given symbol name.
def method_missing(symbol, *args, &block)
%x{
if (#{self}[#{symbol}]) {
return #{self}[#{symbol}].apply(#{self}, args);
}
}
super
end
end But even the following does not get called: class Element
def method_missing(symbol, *args, &block)
p symbol
end
end Patching normal classes with |
So you're saying |
|
Yes, and not even with |
@adambeynon oh, makes sense. |
@adambeynon Ok, thanks for the explanation. Would be nice to have |
As it turns out, trying to make Element.expose :modal Which would add an instance method for calling |
For most of my current use cases the |
As an update, I have (roughly) added native support to This commit basically means that instances of |
So, turns out wrapping jQuery wasn't that great. Most methods needed to keep unwrapping/wrapping instances as before we just made the most out of toll-free bridging. For now, |
👍 |
with opal pointing to master any call to jquery plugins must be exposed explicitly (or wrapped)
cc @fkchang
The text was updated successfully, but these errors were encountered: