-
Notifications
You must be signed in to change notification settings - Fork 441
Fix DocumentFragment interface #199
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
8c52af5
to
57e9684
Compare
baselines/dom.generated.d.ts
Outdated
@@ -3448,7 +3448,11 @@ declare var Document: { | |||
new(): Document; | |||
} | |||
|
|||
interface DocumentFragment extends Node, NodeSelector, ParentNode { | |||
interface DocumentFragment extends Node { | |||
querySelector<K extends keyof ElementTagNameMap>(selectors: K): ElementTagNameMap[K] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so why not extend from NodeSelector?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I specified in microsoft/TypeScript#14246, NodeSelector's properties are defined with ParentNode, not NodeSelector. So we must merge and remove NodeSelector by this pr and #201.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. but why remove NodeSelector
from the extends clause, and then define the functions inline?
it would have been sufficient to just remove ParentNode
from the extends clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I updated my PRs.
57e9684
to
af0d602
Compare
Looking at the histry again, this change has been added in #137 by @YuichiNukiyama to address fix #4400, #7528. Reverting this change will be a breaking change. the ParentNode properties seem to be defined in Chrome, and Edge and referenced in the MDN documentation. This does not seem to be a worth while change, at least with the Selector API is still a working draft. |
This change doesn't affect selector apis. |
As I specified in microsoft/TypeScript#14223, ParentNode properties are NOT defined (implemented) in Edge. Of course Element should inherit ParentNode for its actual apis, but DocumentFragment is NOT. These interfaces have different state of implemetations about ParentNode. Do you really believe ParentNode apis on DocumentFragment? |
I am not an expert on web APIs and browser compt. What i care about is not introducing unneeded breaks for users of the standard library. The changes in #137 explicitly added so unless I missed something, i am inclined to punt on this issue, and wait until the spec reaches the next stage before making any changes. |
So do you accept the error in Edge (to support the unclear spec)? What is your mind? I don't know about that. |
From a user perspective, it is easier to have the API and not use it, than to use it and get a compiler error. IE for example does not support many of the APIs in lib.d.ts today. |
I agree about that in general terms. But MDN says ParentNode properties are not experimenal in Element, experimetal in DocumentFragment. https://developer.mozilla.org/en-US/docs/Web/API/Element So I feel uneasy about the correctness of ParentNode apis in DocumentFragment. Finally, can you believe that correctness? |
I am not really an expert on web APIs, so i am not the best person to comment about the validity of these declarations. it seems that browsers do support them today; and i worry changing them would break valid code for no to little value. |
ok |
Fixes microsoft/TypeScript#14223