GithubHelp home page GithubHelp logo

Comments (14)

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

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.

akre54 avatar akre54 commented on July 27, 2024

This would be a breaking change. Do you see any downsides?

from backbone.nativeview.

akre54 avatar akre54 commented on July 27, 2024

We could also specifically enable useCapture only for change and submit events which might solve this.

from backbone.nativeview.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

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.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

What about other input specific events? Blur and input seem to be effected also

from backbone.nativeview.

akre54 avatar akre54 commented on July 27, 2024

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.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

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.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

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.

akre54 avatar akre54 commented on July 27, 2024

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.

akre54 avatar akre54 commented on July 27, 2024

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.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

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.

akre54 avatar akre54 commented on July 27, 2024

Sure thing. Wanna open a pull with an implementation?

from backbone.nativeview.

ahumphreys87 avatar ahumphreys87 commented on July 27, 2024

Yeah sure, ill get on it tomorrow morning (UK based 😄)

from backbone.nativeview.

cloakedninjas avatar cloakedninjas commented on July 27, 2024

Seen this?

samriley@c0d8210

from backbone.nativeview.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.