Comments (14)
Noticed this works if we change: https://github.com/akre54/Backbone.NativeView/blob/master/backbone.nativeview.js#L125 to enable useCapture
elementAddEventListener.call(this.el, eventName, handler, true);
Any objections to a PR for this?
from backbone.nativeview.
This would be a breaking change. Do you see any downsides?
from backbone.nativeview.
We could also specifically enable useCapture
only for change
and submit
events which might solve this.
from backbone.nativeview.
I haven't noticed any but haven't done any perf tests. Maybe performance would be effected slightly?
Not sure if it would be breaking. The API would still work as it is to the user, would just fix this bug
from backbone.nativeview.
What about other input specific events? Blur and input seem to be effected also
from backbone.nativeview.
The problem with useCapture
is that it would break users' existing stopPropagation
calls. The events would be out of order which is potentially a big deal. We definitely can't enable it by default.
Is it obvious how jQuery does it?
from backbone.nativeview.
Hmm let me investigate that and I'll post back :)
Thanks btw, I'm build a Marionette.Native plugin. This library and
Backbone.Fetch are the main parts of it, nice work!
On Friday, August 26, 2016, Adam Krebs [email protected] wrote:
The problem with useCapture is that it would break users' existing
stopPropagation calls. The events would be out of order which is
potentially a big deal. We definitely can't enable it by default.Is it obvious how jQuery does it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#26 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACZOuCzH-OrXCH6Lyb6OIF8sLrk7wpnrks5qj1f6gaJpZM4JthKr
.
from backbone.nativeview.
So looking at the jquery source, they seem to attach the events to each element individually rather than the document: https://github.com/jquery/jquery/blob/76c5237cc408c01ae67f5c68d39ed6f1e4ef8003/src/event.js#L92-L94
This would probably be quite a large piece of work for this library as we'd need to manage unbinding as well. What do you think @akre54 ?
from backbone.nativeview.
Right. (sorry I was thinking of jQuery's delegate
, or the React event system which *does handle event bubbling). This may be a 'known issue' if we can't work around it without writing a huge layer on top of native events. Any ideas?
* Also the 4-arg form of $.fn.on
from backbone.nativeview.
I'm split on this. I think our two options are to whitelist events that don't bubble (blur
, change
, etc) and special-case them with the useCapture
flag, or acknowledge that these are special events and require you to bind the event handler yourself:
_.first(this.$('input')).addEventListener('change', () => {})
Both have their downsides, but also aren't horrific in the grand scheme of things.
from backbone.nativeview.
Yeah I agree, the $
way of searching for elems with the selector and attaching events to those elems rather than document seems like overkill here.
I'd be happy with a whitelist - I'm yet to see adverse effects using useCapture
so this may well be a good compromise.
from backbone.nativeview.
Sure thing. Wanna open a pull with an implementation?
from backbone.nativeview.
Yeah sure, ill get on it tomorrow morning (UK based
from backbone.nativeview.
Seen this?
from backbone.nativeview.
Related Issues (17)
- _domEvents prototype attribute is useless? HOT 1
- Am I missing something? $el still exists. HOT 7
- Exoskeleton + Browserify HOT 5
- Backbone.$ is not a function HOT 1
- this._domEvents isn't initialized properly when mixing into Backbone.View HOT 3
- Should delegate align with jQuery behavior? HOT 11
- Undelegating differs from jQuery HOT 1
- Register on npm HOT 5
- Integrating into core backbonejs HOT 1
- Working with require()'s HOT 7
- events issues when no el is set HOT 3
- Blur/Focus do not bubble up and therefore not accessible via this.delegate HOT 1
- Illegal invocation due to this.el being null
- bower install backbone.nativeview does not work HOT 1
- Publish 0.3.0 to NPM HOT 2
- How to "Backbone.NativeView + Browserify" HOT 2
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 backbone.nativeview.