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
Change deepPath() back to path (a FrozenArray<EventTarget> attribute) #428
Comments
I think I would be okay with this change. I initially pressed for "deep" since I thought we might have "path" meaning the path of the event without open shadow trees and "deep" could be a convention for APIs that include open shadow trees. However, as we consider more features and their integration with shadow trees, the more it seems like some of them might leak open shadow trees and not follow this "deep" naming. It does not really help that we still haven't established solid principles around this. Is anyone keeping track of APIs that leak open shadow trees in some way? |
Even if we're renaming |
It's a good opportunity to see the history of
Given this history, what is the best choice for us? Option A) Event.path as a property, including the behavior change of 4.
Option B) Event.path as a property, also reverting behavior change of 4.
Option C) Event.path() as a method
Option D) No action. Event.deepPath() as a method.
|
I'm not sure if option C would break the Web for Blink. In theory, you should be able to add a sequence like object that can be called. i.e. I'm gonna also add a new option: Option E) Add Event.getPath() or Event.currentPath() as a method |
#428 (comment) is very interesting, and I can see why that tipped the balance in favor of a method. However, the main benefit of If the alternatives @hayatoito outlines, Option A seems worth exploring. It seems pretty likely that this detail could be changed without breaking the web. To access |
@foolip : well, the problem here is that |
Yes, but that shouldn't be an additional problem, as long as it has to change once (which it must) then the model is already one where the attribute's value can change. However, it would still be possible to make |
@foolip : no :( It can potentially change for every I also don't see the value of |
No. As long as event.path returns an immutable Also developers can re-use the same event object instance, in dispatching yet another (synthetic) event. |
@rniwa, I acknowledged that it can change for every node |
What's the advantage of making |
Ops. I understand you meant that the expression of I thought that you meant:
|
@bzbarsky called it a "very reasonable expectation" but of course it's not a matter of use cases. Having a |
Having properties that return a new object every time is an antipattern for several reasons:
There are probably more reasons that I can't think of right now this time of night. Again, this has been discussed to death for years now... It's unfortunate that after this has all been known for years the shadow DOM implementors in Blink decided to add and then ship in release the "create a new object each time" behavior for Anyway, having a I would be somewhat opposed to implementing the " |
See also https://w3ctag.github.io/design-principles/#attributes-like-data IMO option D seems quite reasonable. Blink will have to pay a legacy tax for a long time having shadow DOM v0 features. That is sometimes the unfortunate cost of being a first-mover. event.path is not a very high cost as far as I can tell. |
I agree that an IDL attribute that creates a new object each time doesn't meet author expectation, and this is why we had a consensus to make it a method instead. I was asking use cases more in terms of semantics. Why do authors want to use the result of |
Yes, a method would have been better, and I understand that nobody objected when this change was made. But the situation we find ourselves in is that nobody can say if or when I think the options are:
Because I think x is a relatively small number, option 2 looks risky to me. |
Are we talking about just Blink having to support |
I mean that |
Why? Only Blink implements |
Having to keep
It's not an ideal API, but is it so bad that it cannot be salvaged? |
I implemented the feature as |
It's also implemented in Blink, behind a disabled-by-default flag as it appears to be in WebKit. Since #428 (comment) I have learned that @rniwa, would this be acceptable to you and WebKit, or are there additional problems not addressed? |
@foolip and the event object would hold a weak reference? It seems a little harder to optimize and it would no longer clearly identify the API as piercing through the shadow boundary. (Is there precedent for that elsewhere?) |
No, like I've repeatedly said, we want |
@rniwa, is there any problem in addition to the lack of |
@annevk, I think the event object would hold a strong reference, why weak? At the end of dispatch it would be replaced by an empty array. But of course none of the arrays need to be created eagerly, if the attribute is never read then no actual array would be created. It's probably easier to spec it as a internal slot, though. |
My preference is:
@foolip, Whether using |
Sure, here's how I view the options. Where there is uncertainty, I'll give a percentage of the odds I'd give if running a (very strange) lottery. If the real odds were much different and could be known, I might view things differently. Option A) Event.path as a property, including the behavior change of 4.
(I assume this also includes the changes during dispatch when crossing closed shadow tree boundaries, not just the final emptying of the array. This doesn't change the situation because v0 is open.) Option B) Event.path as a property, also reverting behavior change of 4.
Option C) Event.path() as a method
Option D) No action. Event.deepPath() as a method.
Option E) Add Event.getPath() or Event.currentPath() |
Where did you get those probabilities? |
They are merely the best guesses I'd use if anything were at stake. To justify them somewhat: 10% chance of failure on Option A is because changing the return value after the end of dispatch must be a small minority of the total usage. Most event handlers don't save the event and look at it again later. https://bit.ly/blinkintents lists many small behavioral changes that worked out, many that I'd consider riskier. 80% risk that Event.path will never be removed from Blink is based on the first comment in this thread, that "we have no idea about how risky such a change would be" and thus are stuck. Maybe someone with extreme patience could show it safe using httparchive analysis, or some other new tool, eventually. 20% risk of this spreading due to Blink compat is the most speculative. I want it to be 0%, but it's happened before with IE and WebKit, so doesn't seem too far fetched. Another way it could happen is that Edge has to copy it because they identify as Chrome, and then it's hard to see it ever going away, even if it's not implemented elsewhere. If my guesses seem wildly wrong, or if they aren't even the right things to guess about, I'm also interested in seeing how others see this playing out. |
I don't think the risk is high enough to revert this change. FWIW, if this is a compat issue, I'd imagine the lack of support for |
Impressed how the consistency and quality of the design seems to be put at risk due to an existing implementation of an unfinished spec. Breaking the web? The experimental web is not the web... It's the use at your own risk web. |
@rniwa, sure, the But, I'm not getting any traction on this, so I'll walk away. Because the current path was agreed upon by all relevant parties (I am not one) I think Blink should be prepared to take greater risks to get rid of v0, even though I think this is one that could have been averted. |
@foolip, I got it. Let me close this issue without any action. |
Continuing from #361 (comment):
@annevk also asks "whether Blink includes WindowProxy in the path", and it would be good to flesh out the definition a bit.
Here's a quick and basic test for that:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3975
In Chrome Canary it prints
["HTMLButtonElement","ShadowRoot","HTMLDivElement","HTMLBodyElement","HTMLHtmlElement","HTMLDocument","Window"]
so the Window(Proxy) is included in the path.The text was updated successfully, but these errors were encountered: