Skip to content

Make navigator.clipboard fallible #2598

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 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions crates/web-sys/src/features/gen_ClipboardEvent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,4 @@ extern "C" {
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn clipboard_data(this: &ClipboardEvent) -> Option<DataTransfer>;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new(type_: &str) -> Result<ClipboardEvent, JsValue>;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "ClipboardEventInit")]
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `ClipboardEventInit`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new_with_event_init_dict(
type_: &str,
event_init_dict: &ClipboardEventInit,
) -> Result<ClipboardEvent, JsValue>;
}
2 changes: 1 addition & 1 deletion crates/web-sys/src/features/gen_Navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ extern "C" {
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn clipboard(this: &Navigator) -> Clipboard;
pub fn clipboard(this: &Navigator) -> Option<Clipboard>;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "WakeLock")]
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = wakeLock)]
Expand Down
17 changes: 9 additions & 8 deletions crates/web-sys/webidls/unstable/Clipboard.webidl
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Clipboard API and events
* W3C Working Draft, 5 June 2019
* W3C Working Draft, 4 June 2021
* The origin of this IDL file is:
* https://www.w3.org/TR/2019/WD-clipboard-apis-20190605/
* https://www.w3.org/TR/2021/WD-clipboard-apis-20210604/
*/

dictionary ClipboardEventInit : EventInit {
DataTransfer? clipboardData = null;
};

[Constructor(DOMString type, optional ClipboardEventInit eventInitDict), Exposed=Window]
[Exposed=Window]
interface ClipboardEvent : Event {
constructor(DOMString type, optional ClipboardEventInit eventInitDict = {});
readonly attribute DataTransfer? clipboardData;
};

partial interface Navigator {
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
[SecureContext, SameObject] readonly attribute Clipboard? clipboard;
};

typedef sequence<ClipboardItem> ClipboardItems;
Expand All @@ -33,12 +34,12 @@ typedef Promise<ClipboardItemDataType> ClipboardItemData;

callback ClipboardItemDelayedCallback = ClipboardItemData ();

[Constructor(record<DOMString, ClipboardItemData> items,
optional ClipboardItemOptions options),
Exposed=Window] interface ClipboardItem {
[Exposed=Window] interface ClipboardItem {
constructor(record<DOMString, ClipboardItemData> items,
optional ClipboardItemOptions options = {});
static ClipboardItem createDelayed(
record<DOMString, ClipboardItemDelayedCallback> items,
optional ClipboardItemOptions options);
optional ClipboardItemOptions options = {});

readonly attribute PresentationStyle presentationStyle;
readonly attribute long long lastModified;
Expand Down