Store link to original preventDefault method under separate property name
dashukin opened this issue · 8 comments
In some cases legacy code may create event handlers via libraries that do not support passive events option (e.g. jquery click handlers within i.e. mobile application). In order to perform transition to default passive events it might be good to save original .preventDefault method so it can be used as a safe point of passive events integration.
Do you think it is posisble to add it?
Regards!
Hey @dashukin,
Actually resolution of #19 was intended to fix any compatibility issues with third-party libraries (I had mainly jQuery in mind).
Can you show us any example in which you get an error/some unexpected behaviour?
Nevertheless I think that adding pointer to original function may be helpful in some uncommon situations, so why not?
I could put it under an _original
attribute of function created in prepareSafeListener
, so it would be accessible under .addEventListener._original
.
@zzarcon what do you think?
Hey, @FRSgit
thank you for quick reply! Unfortunatelly I still canot reproduce the issue I'm facing with in a separate sandbox, but will try to dive into the details more deeply. In general I can see that chrome mobile emulator fires some handlers with click events, with preventDefault method set to noop function, while on real devices everything works fine... I will let you know when any new details are received so we could analyze if this a setup issue or something that could be handled from your library.
Okay, so if you can try to come up with some reproducing-scenario it would be perfect for me.
But if it won't be so simple then please give me more info about you environment & codebase you use when getting this errors.
As I understand that problem can be connected with sandbox in which you run your app, but I cannot be 100% sure until I see your configuration.
We are in the same timezone (or almost-same) I guess, so you can always try to show me your problem via some screensharing app (like hangouts or sth).
Hi @FRSgit. The element.addEventListener._original function just worked fine for me as a workaround for the issue with d3-drag that I had here: d3/d3-drag#51
Just FYI, so you know it was actually useful for someone :)
Also, there was no interest in fixing the issue in d3 upstream: d3/d3-drag#52
Well, I completely understand that they doesn't want any non-standard functionalities in their code.
For now, the only thing you can (and should) do when using default-passive-events
library is to bring back _original
listener before initializing d3-drag
.
Of course we could support some parameter which you would put on a element to flag that it should be ignored by our library, but I'm not sure if that's not an overkill. We want to keep library as simple & fast as possible.
Okay, closing this now as _original
function was implemented correctly and is already included in README page. Hopefully more of you will be happy to use it 😃