-
Notifications
You must be signed in to change notification settings - Fork 299
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
cancelBubble legacy property #211
Comments
I think we should just define @smaug----, objections? |
In Gecko UIEvent has that indeed and it sets the propagation stopped flag. This is really ancient stuff. Looks like the property works in a bit different way in different browsers. In Gecko it maps to |
but yeah, ok to spec, although it is ancient bad API. |
oh, it is also old IEism. Totally forgot. IE didn't use to have stopPropagation(), only cancelBubble |
Our usage stats suggest that it's still pretty popular (though falling). This will be tainted somewhat by event copying code, but 4% of page views is huge compared to what we normally see for event copying (eg. 0.2% for webkitMovementX before we removed it). I Get a ton of hits for "cancelBubble" in httpArchive. So yeah we're unlikely to be able to remove it. But if Gecko just has it mapped to stopPropagation then perhaps that would be web compatible for us (certainly simpler). What does Edge do? We might need to add UseCounters measuring how often the difference matters (eg. how often it's set back to false, or set from within capturing handlers while there are still other capturing handlers to run). That said, if IE, Edge, WebKit and blink are all consistent here already, maybe it's best to just define it exactly as it's implemented in those browsers. I guess it's not completely crazy to think that some capturing handler may want to prevent all bubbling without preventing the rest of the capture or target phases. @tkent-google any thoughts? |
In Blink it's a separate internal slot, and used in two places: @inexorabletash, any idea why there's special event dispatch code for IndexedDB? If we end up having to specify something by the name |
@foolip he mentioned in the above comment that there's a ton of hits. |
Also, IndexedDB likely has special dispatch code because Blink's implementation of event paths is not generic I believe. |
Ah, OK, then I change my question to "what do the hits look like"? I guess most of them set it to true because that's the only useful thing one can do with the API? |
FWIW, looks like there was code in Gecko which tried to allow changing cancelBubble flag only during target/bubble phase[1], but it was apparently never working, if I trust my own comment from 10 years ago https://bugzilla.mozilla.org/show_bug.cgi?id=330494#c3 [1] I think this would be to mimic old IE. IIRC, it has effectively just target and bubble phases. |
I'm swamped right now and can't dig in deeply, but here's the first 5000 results. Looks like jQuery, mootools some twitter libraries are major users. Want to spot check some of these and let us know what you find? |
I opened 10 of them "at random" and took a quick look. Mostly it's used as a fallback when In https://maps.googleapis.com/maps/api/js and http://w.sharethis.com/share5x/js/stcommon.2b05accc08f1ee42fe1983647ab923ea.js and multiple other scripts it's used together with In http://www.speedup.ir/angular/app/scripts/vendor/jquery.nicescroll.js there are many uses, most similar to the above but one that's gated on else if (document.fireEvent) {
this.notifyScrollEvent = function(el) {
var e = document.createEventObject();
el.fireEvent("onscroll");
e.cancelBubble = true;
};
} As long as Edge has removed In http://kolelnasmag.com/wp-content/themes/Fikra%20Mag3/js/uisearch.js there's an In https://static.xx.fbcdn.net/rsrc.php/v2iaFb4/yH/l/en_US/0bcWBIJHikk.js @domenic makes an appearance :) /**
* @generated SignedSource<<4c94898b765e9ddb7bac02513e528723>>
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !! This file is a check-in of a static_upstream project! !!
* !! !!
* !! You should not modify this file directly. Instead: !!
* !! 1) Use `fjs use-upstream` to temporarily replace this with !!
* !! the latest version from upstream. !!
* !! 2) Make your changes, test them, etc. !!
* !! 3) Use `fjs push-upstream` to copy your changes back to !!
* !! static_upstream. !!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic
* Denicola Anyway, in that file there's a bit of code that I saw in a few places, seems like this is the unminified code: It looks like this isn't actually an That was a very quick check, but I didn't see anyone setting |
From this description it sounds like we don't even know for sure that removing Or is the cost of having it as an alias of |
If we could get away with making it an alias rather than its own primitive I think that'd be fantastic. Removing it altogether given the usage numbers seems rather risky. |
So a few things would be worth measuring, then:
I could add this to Blink but need to focus on Media Session for a bit right now. @RByers? |
Sorry I'm really swamped right now, but this is really DOM team, not input team. @tkent-google WDYT, worth exploring? Might someone on the DOM team be interested in doing the measurements @foolip suggests? |
Yeah, we should collect such data definitely. I filed crbug.com/603377. |
Do we already know how different browser engines handle cancelBubble? It feels like we should write some extensive tests covering using cancelBubble during different event phases and with and without stopPropagation() etc. Would anyone have time to write such tests? |
In Blink, for each target where |
Okay, so the difference with stop propagation is that stop propagation affects all phases. Seems reasonably safe to change |
it does not work AT_TARGET? |
@smaug---- why would something named "cancel bubble", cancel target? (You can set it there, of course.) |
no idea. I wasn't asking that. I was just asking what the implementation actually does. I was asking mainly because AT_TARGET is special. Even though an listener is added to capture phase, listener AT_TARGET is called. |
That will call listeners on the target in Chrome. |
The |
The UseCounters got committed: https://bugs.chromium.org/p/chromium/issues/detail?id=603377#c3 |
Chrome 52 (which includes the UseCounters) was promoted to Stable yesterday. |
Usage timelines here: But they're not recent enough to show the beginning of the S-curve, it'll probably be a week or so before one can see something useful. |
With ~25 days of data, and the metrics looking somewhat stable:
1.306% as of yesterday. So it's indeed common (relatively speaking). 0% for the entire timeline. So it's indeed extremely rare.
Peaked at 0.027% on the chart. So it seems like |
Given the usage I'd certainly LGTM a simplification of Since Gecko has this on |
Yeah, putting it directly on |
I agree that making this a |
We do know that supporting "selectstart" events as Note that either I messed up debugging the Firefox side there or OWA is actually attaching different listeners or creating a different DOM depending on whether |
Filed https://bugs.chromium.org/p/chromium/issues/detail?id=657651 to try to keep things moving forward. |
Missed the ping above, sorry. IIRC, the Indexed DB-specific code is because it's the only place other than DOM where events bubble; it's effectively an implementation of the "get the parent" mechanism for EventTarget. |
Gecko moved |
More delightful garbage from the past. Fixes #211.
This came up in review: do we want to prevent un-stopPropagation() going forward or do we want to keep that behavior? Basically, do we want to make setting it to false be a no-op rather than have that unset the internal flag? |
FWIW, the metrics say there's virtually no code on the Web that does |
Tests by @cvrebert to help inform a spec change here |
@smaug---- and @foolip can you comment on whether you are okay with making setting cancelBubble to false a no-op? As mentioned above the metrics indicate this to be safe. |
Yes, I think that's quite reasonable. @tkent-google, WDYT? |
I think that sounds good. |
Sorry for being late but on WebKit side, I'd be OK making cancelBubble=true an alias for stopPropagation(). Regarding cancelBubble=false, my personal preference would be to un-stopPropagation() rather than making it a no-op. This is simply because having cancelBubble=true do something and cancelBubble=false be a no-op seems like a weird API. Also, I think there is very little cost (in terms of code complexity) to make cancelBubble=false clear the stopPropagation flag. That said, I am not opposed to making it a no-op if this is what others prefer. |
The reason for the no-op is that otherwise we have a legacy API with a new feature, which is rather odd. |
| Yes, I think that's quite reasonable. @tkent-google, WDYT? +1 |
Discussion at whatwg/dom#211 and standard change at whatwg/dom#383.
More delightful garbage from the past. Tests: web-platform-tests/wpt#4304. Fixes #211.
According to spec https://dom.spec.whatwg.org/#dom-event-cancelbubble, setting cancelBubble to true is considered as an alias to stopPropagation(), setting cancelBubble to false is a no-op. Detail discussion is on whatwg/dom#211. BUG=675549 Review-Url: https://codereview.chromium.org/2641953006 Cr-Commit-Position: refs/heads/master@{#446118}
UIEvent.cancelBubble
works in all modern browsers.Testcase: http://jsbin.com/jufexu/edit?html,css,js,output
Event.cancelBubble
works in all modern browsers (Chrome, Safari, Edge, IE11) except Firefox.Testcase: http://jsbin.com/wirelo/edit?html,js,output
To accurately reflect reality, I propose speccing at least one of these properties.
The text was updated successfully, but these errors were encountered: