Skip to content

Commit 1e41529

Browse files
authored
bump the IDL for Clipboard, and make navigator.clipboard fallible (#2598)
1 parent b2caf83 commit 1e41529

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

crates/web-sys/src/features/gen_ClipboardEvent.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,4 @@ extern "C" {
2727
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2828
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
2929
pub fn clipboard_data(this: &ClipboardEvent) -> Option<DataTransfer>;
30-
#[cfg(web_sys_unstable_apis)]
31-
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
32-
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
33-
#[doc = ""]
34-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
35-
#[doc = ""]
36-
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`*"]
37-
#[doc = ""]
38-
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
39-
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
40-
pub fn new(type_: &str) -> Result<ClipboardEvent, JsValue>;
41-
#[cfg(web_sys_unstable_apis)]
42-
#[cfg(feature = "ClipboardEventInit")]
43-
#[wasm_bindgen(catch, constructor, js_class = "ClipboardEvent")]
44-
#[doc = "The `new ClipboardEvent(..)` constructor, creating a new instance of `ClipboardEvent`."]
45-
#[doc = ""]
46-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/ClipboardEvent)"]
47-
#[doc = ""]
48-
#[doc = "*This API requires the following crate features to be activated: `ClipboardEvent`, `ClipboardEventInit`*"]
49-
#[doc = ""]
50-
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
51-
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
52-
pub fn new_with_event_init_dict(
53-
type_: &str,
54-
event_init_dict: &ClipboardEventInit,
55-
) -> Result<ClipboardEvent, JsValue>;
5630
}

crates/web-sys/src/features/gen_Navigator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ extern "C" {
127127
#[doc = ""]
128128
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
129129
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
130-
pub fn clipboard(this: &Navigator) -> Clipboard;
130+
pub fn clipboard(this: &Navigator) -> Option<Clipboard>;
131131
#[cfg(web_sys_unstable_apis)]
132132
#[cfg(feature = "WakeLock")]
133133
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = wakeLock)]

crates/web-sys/webidls/unstable/Clipboard.webidl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/*
33
* Clipboard API and events
4-
* W3C Working Draft, 5 June 2019
4+
* W3C Working Draft, 4 June 2021
55
* The origin of this IDL file is:
6-
* https://www.w3.org/TR/2019/WD-clipboard-apis-20190605/
6+
* https://www.w3.org/TR/2021/WD-clipboard-apis-20210604/
77
*/
88

99
dictionary ClipboardEventInit : EventInit {
1010
DataTransfer? clipboardData = null;
1111
};
1212

13-
[Constructor(DOMString type, optional ClipboardEventInit eventInitDict), Exposed=Window]
13+
[Exposed=Window]
1414
interface ClipboardEvent : Event {
15+
constructor(DOMString type, optional ClipboardEventInit eventInitDict = {});
1516
readonly attribute DataTransfer? clipboardData;
1617
};
1718

1819
partial interface Navigator {
19-
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
20+
[SecureContext, SameObject] readonly attribute Clipboard? clipboard;
2021
};
2122

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

3435
callback ClipboardItemDelayedCallback = ClipboardItemData ();
3536

36-
[Constructor(record<DOMString, ClipboardItemData> items,
37-
optional ClipboardItemOptions options),
38-
Exposed=Window] interface ClipboardItem {
37+
[Exposed=Window] interface ClipboardItem {
38+
constructor(record<DOMString, ClipboardItemData> items,
39+
optional ClipboardItemOptions options = {});
3940
static ClipboardItem createDelayed(
4041
record<DOMString, ClipboardItemDelayedCallback> items,
41-
optional ClipboardItemOptions options);
42+
optional ClipboardItemOptions options = {});
4243

4344
readonly attribute PresentationStyle presentationStyle;
4445
readonly attribute long long lastModified;

0 commit comments

Comments
 (0)