Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

falsandtru
Copy link
Contributor

@falsandtru
Copy link
Contributor Author

@falsandtru falsandtru force-pushed the DocumentFragment branch 2 times, most recently from 8c52af5 to 57e9684 Compare February 24, 2017 05:23
@@ -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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 1, 2017

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.

@falsandtru
Copy link
Contributor Author

This change doesn't affect selector apis.

@falsandtru
Copy link
Contributor Author

the ParentNode properties seem to be defined in Chrome, and Edge and referenced in the MDN documentation.

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?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 2, 2017

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 ParentNode to the heritage clause of DocumentFragment, and these APIs seem supported in Firefox:
image

And chrome:
image

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.

@falsandtru
Copy link
Contributor Author

So do you accept the error in Edge (to support the unclear spec)? What is your mind? I don't know about that.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 2, 2017

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.

@falsandtru
Copy link
Contributor Author

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
https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment

So I feel uneasy about the correctness of ParentNode apis in DocumentFragment. Finally, can you believe that correctness?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 7, 2017

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.

@falsandtru
Copy link
Contributor Author

ok

@falsandtru falsandtru closed this Mar 7, 2017
@falsandtru falsandtru deleted the DocumentFragment branch April 19, 2017 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants