-
Notifications
You must be signed in to change notification settings - Fork 13k
Bring over last 3.9 dom changes #37502
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1697,6 +1697,12 @@ interface ShadowRootInit { | |
mode: ShadowRootMode; | ||
} | ||
|
||
interface ShareData { | ||
text?: string; | ||
title?: string; | ||
url?: string; | ||
} | ||
|
||
interface SpeechSynthesisErrorEventInit extends SpeechSynthesisEventInit { | ||
error: SpeechSynthesisErrorCode; | ||
} | ||
|
@@ -10733,6 +10739,7 @@ interface Navigator extends MSFileSaver, MSNavigatorDoNotTrack, NavigatorAutomat | |
msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; | ||
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise<MediaKeySystemAccess>; | ||
sendBeacon(url: string, data?: BodyInit | null): boolean; | ||
share(data?: ShareData): Promise<void>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this actually be optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably shouldn't - otherwise all other DOM apis would kinda need it, so all of them are like this |
||
vibrate(pattern: number | number[]): boolean; | ||
} | ||
|
||
|
@@ -19225,7 +19232,7 @@ interface BlobCallback { | |
} | ||
|
||
interface CustomElementConstructor { | ||
new (): HTMLElement; | ||
new (...params: any[]): HTMLElement; | ||
} | ||
|
||
interface DecodeErrorCallback { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The spec says that at least one of these properties must be present, but my hunch is it would likely be annoying to make this a union.
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.
Hi, I hope I'm not just adding noise here, but we recently added this type locally and tackled the same problem. This is what we came up with if it helps:
But I don't know if a goal for
dom.d.ts
types is to avoid complex types likeAtLeastOneRequired
...Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, I think that would be a goal. In this case the fully correct version is not too much to write out:
But I think even that may be overkill.
Uh oh!
There was an error while loading. Please reload this page.
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.
Fair enough; and I would say preferred from a clarity and performance point of view.
I would prefer the union myself, but I suppose people can always do their own overrides locally like us.
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.
These are code-gen'd from the same source which browsers use. So for this example: https://www.w3.org/TR/web-share
Which pulls out:
Which gets codegens to extend the Navigator, and create a new type:
We could make those types, but then we're not using the same source of truth as browsers
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.
We can change before the RC if it's really an issue. If it's concerning, maybe we have the generator declare this as a type alias instead to avoid merging and future-proof it