Comments (6)
I wondered if it should provide that, but I figured that most of the time you'd need it. you'd be operating in JS already, so you could do element.native
in JS to get it.
It's entirely possible I've overlooked a use case for this, though. Can you explain a bit about what you're trying to do?
from bowser.
For example, I have a method:
def inject_to_body(elem)
end
And I want to support native elements, opal-browser, and any other libs that wraps native elements somehow. So the best solution is to convert elem
to native.
def inject_to_body(elem)
elem = elem.to_n unless native?(elem)
# inject to body
end
#to_n
is some kind of opal
standard I think to convert wrapped object to native.
from bowser.
It's not a bad idea. I was just trying to understand the use case. I haven't looked too closely at the Native
mixin yet, but it may bring in more functionality than necessary. I'd rather just add the to_n
method first until we can see if there's enough functionality needed to justify including the mixin.
I wanted to keep a similar API to opal-browser
to make transitioning to bowser
easy — so far, in upgrading Clearwater pre-1.0-beta apps (which used opal-browser
) to the 1.0 beta (which uses bowser
), I've only ever had to change the element
attribute of the app itself, which I consider pretty good. If you need a bit more API compatibility, we can definitely look into it.
from bowser.
BTW Why you just don't use an opal way to make a wrapper ? I mean include Native
, alias_native
etc ?
from bowser.
I prefer to remove dependencies if possible. I don't know if native
is already loaded (likely, but not guaranteed), but if it's not I'd prefer not to load it for two reasons: adding it expands API surface and increases the JS payload size.
Expanding API surface isn't exactly dangerous, but it can be problematic in that people begin relying on other methods that just happen to be there because they came with the mixin. If we then swap out the mixin later for any reason, it may cause unintended regressions.
In regards to payload size, bloated JS payloads are the reason I switched from opal-browser
to Bowser. Is the convenience of being able to say alias_native
worth loading an entire module? I'm not sure. I'm also not sure if this one is even something to worry about, since it's entirely possible that native
is likely to be loaded already by another dependency of any given Opal app.
from bowser.
Fixed in cd9e31a (Element
) and f5fb5a8 (Event
)
from bowser.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bowser.