-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Adds event modifiers using | character #1641
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
Conversation
Nvm, it was only 4 tests. |
Still need to add tests for event modifiers that aren't
|
Thanks for this. A couple of things I wonder about and would be interested to hear views on:
node.addEventListener('click', handler, {
capture: false,
passive: true,
once: true
}); ...behaves like this: node.addEventListener('click', handler, {
capture: true,
passive: false,
once: false
}); We have a // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
var passiveSupported = false;
try {
var options = Object.defineProperty({}, "passive", {
get: function() {
passiveSupported = true;
}
});
window.addEventListener("test", options, options);
window.removeEventListener("test", options, options);
} catch(err) {
passiveSupported = false;
}
// capture: true
node.addEventListener('click', handler, true);
// passive: true, capture: false
node.addEventListener('click', handler, passiveSupported ? {
passive: true
} : false);
// once: true
node.addEventListener('click', once(handler), false);
function once(fn) {
let called = false;
return function() {
if (called) return;
called = true;
return fn.apply(this, arguments);
};
} Separately, it occurs to me that if the |
I was thinking about it and I think
I don't have experience with |
|
This is great! I'm definitely a fan of splitting them up like this 🙌 |
Hey @GarrettGeorge, any progress on this? Are you still planning on working on it? |
I'm still working on |
Closing this in favour of #1819 — thanks for the initial push @GarrettGeorge! Will be great to have this feature available |
Issue Ref: #1088
Uses the pipe character as referenced by Rich here.
Utilizes the 5 options similar to those from Vue listed here
Doesn't break any existing event handlers because the options default to false for all.
Doesn't work with custom events.