Skip to content

Commit 4e6dcbe

Browse files
lukaslihotzkidaxpedda
authored andcommitted
Deprecate HtmlMenuItemElement and parts of HtmlMenuElement
1 parent a9dea47 commit 4e6dcbe

File tree

7 files changed

+46
-72
lines changed

7 files changed

+46
-72
lines changed

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

+15
Original file line numberDiff line numberDiff line change
@@ -11,98 +11,113 @@ extern "C" {
1111
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement)"]
1212
#[doc = ""]
1313
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
14+
#[deprecated(note = "Absent in all major browsers")]
1415
pub type HtmlMenuItemElement;
16+
#[deprecated(note = "Absent in all major browsers")]
1517
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = type)]
1618
#[doc = "Getter for the `type` field of this object."]
1719
#[doc = ""]
1820
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/type)"]
1921
#[doc = ""]
2022
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
2123
pub fn type_(this: &HtmlMenuItemElement) -> String;
24+
#[deprecated(note = "Absent in all major browsers")]
2225
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = type)]
2326
#[doc = "Setter for the `type` field of this object."]
2427
#[doc = ""]
2528
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/type)"]
2629
#[doc = ""]
2730
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
2831
pub fn set_type(this: &HtmlMenuItemElement, value: &str);
32+
#[deprecated(note = "Absent in all major browsers")]
2933
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = label)]
3034
#[doc = "Getter for the `label` field of this object."]
3135
#[doc = ""]
3236
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/label)"]
3337
#[doc = ""]
3438
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
3539
pub fn label(this: &HtmlMenuItemElement) -> String;
40+
#[deprecated(note = "Absent in all major browsers")]
3641
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = label)]
3742
#[doc = "Setter for the `label` field of this object."]
3843
#[doc = ""]
3944
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/label)"]
4045
#[doc = ""]
4146
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
4247
pub fn set_label(this: &HtmlMenuItemElement, value: &str);
48+
#[deprecated(note = "Absent in all major browsers")]
4349
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = icon)]
4450
#[doc = "Getter for the `icon` field of this object."]
4551
#[doc = ""]
4652
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/icon)"]
4753
#[doc = ""]
4854
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
4955
pub fn icon(this: &HtmlMenuItemElement) -> String;
56+
#[deprecated(note = "Absent in all major browsers")]
5057
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = icon)]
5158
#[doc = "Setter for the `icon` field of this object."]
5259
#[doc = ""]
5360
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/icon)"]
5461
#[doc = ""]
5562
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
5663
pub fn set_icon(this: &HtmlMenuItemElement, value: &str);
64+
#[deprecated(note = "Absent in all major browsers")]
5765
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = disabled)]
5866
#[doc = "Getter for the `disabled` field of this object."]
5967
#[doc = ""]
6068
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/disabled)"]
6169
#[doc = ""]
6270
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
6371
pub fn disabled(this: &HtmlMenuItemElement) -> bool;
72+
#[deprecated(note = "Absent in all major browsers")]
6473
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = disabled)]
6574
#[doc = "Setter for the `disabled` field of this object."]
6675
#[doc = ""]
6776
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/disabled)"]
6877
#[doc = ""]
6978
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
7079
pub fn set_disabled(this: &HtmlMenuItemElement, value: bool);
80+
#[deprecated(note = "Absent in all major browsers")]
7181
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = checked)]
7282
#[doc = "Getter for the `checked` field of this object."]
7383
#[doc = ""]
7484
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/checked)"]
7585
#[doc = ""]
7686
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
7787
pub fn checked(this: &HtmlMenuItemElement) -> bool;
88+
#[deprecated(note = "Absent in all major browsers")]
7889
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = checked)]
7990
#[doc = "Setter for the `checked` field of this object."]
8091
#[doc = ""]
8192
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/checked)"]
8293
#[doc = ""]
8394
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
8495
pub fn set_checked(this: &HtmlMenuItemElement, value: bool);
96+
#[deprecated(note = "Absent in all major browsers")]
8597
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)]
8698
#[doc = "Getter for the `radiogroup` field of this object."]
8799
#[doc = ""]
88100
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/radiogroup)"]
89101
#[doc = ""]
90102
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
91103
pub fn radiogroup(this: &HtmlMenuItemElement) -> String;
104+
#[deprecated(note = "Absent in all major browsers")]
92105
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)]
93106
#[doc = "Setter for the `radiogroup` field of this object."]
94107
#[doc = ""]
95108
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/radiogroup)"]
96109
#[doc = ""]
97110
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
98111
pub fn set_radiogroup(this: &HtmlMenuItemElement, value: &str);
112+
#[deprecated(note = "Absent in all major browsers")]
99113
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)]
100114
#[doc = "Getter for the `defaultChecked` field of this object."]
101115
#[doc = ""]
102116
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/defaultChecked)"]
103117
#[doc = ""]
104118
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
105119
pub fn default_checked(this: &HtmlMenuItemElement) -> bool;
120+
#[deprecated(note = "Absent in all major browsers")]
106121
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)]
107122
#[doc = "Setter for the `defaultChecked` field of this object."]
108123
#[doc = ""]

crates/web-sys/tests/wasm/html_element.rs

-8
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,6 @@ fn test_html_element() {
121121
);
122122
assert!(element.is_content_editable(), "Should be content_editable");
123123

124-
/*TODO doesn't work in Chrome
125-
// TODO verify case where menu is passed
126-
match element.context_menu() {
127-
None => assert!(true, "Shouldn't have a custom menu set"),
128-
_ => assert!(false, "Shouldn't have a custom menu set")
129-
};
130-
*/
131-
132124
// TODO: This test is also broken in Chrome (but not Firefox).
133125
// assert!(!element.spellcheck(), "Shouldn't be spellchecked");
134126
element.set_spellcheck(true);

crates/web-sys/tests/wasm/main.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod br_element;
1111
pub mod button_element;
1212
pub mod console;
1313
pub mod div_element;
14+
pub mod dom_point;
1415
pub mod element;
1516
pub mod event;
1617
pub mod head_element;
@@ -21,13 +22,10 @@ pub mod hr_element;
2122
pub mod html_element;
2223
pub mod html_html_element;
2324
pub mod image_data;
24-
pub mod input_element;
25-
//TODO: Both menu-related tests completely break in Chrome, but run fine in Firefox.
26-
//pub mod menu_element;
27-
//pub mod menu_item_element;
28-
pub mod dom_point;
2925
pub mod indexeddb;
26+
pub mod input_element;
3027
pub mod location;
28+
pub mod menu_element;
3129
pub mod meta_element;
3230
pub mod meter_element;
3331
pub mod mod_elements;
+11-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use wasm_bindgen_test::*;
21
use wasm_bindgen::prelude::*;
2+
use wasm_bindgen_test::*;
33
use web_sys::HtmlMenuElement;
44

55
#[wasm_bindgen(module = "/tests/wasm/element.js")]
@@ -11,15 +11,17 @@ extern "C" {
1111
fn test_menu_element() {
1212
let menu = new_menu();
1313

14-
menu.set_type("toolbar");
15-
assert_eq!(menu.type_(), "toolbar", "Menu should have the type value we gave it.");
16-
17-
menu.set_label("Menu label here");
18-
assert_eq!(menu.label(), "Menu label here", "Menu should have the label value we gave it.");
19-
2014
menu.set_compact(true);
21-
assert_eq!(menu.compact(), true, "Menu should be compact after we set it to be compact.");
15+
assert_eq!(
16+
menu.compact(),
17+
true,
18+
"Menu should be compact after we set it to be compact."
19+
);
2220

2321
menu.set_compact(false);
24-
assert_eq!(menu.compact(), false, "Menu should not be compact after we set it to be not-compact.");
22+
assert_eq!(
23+
menu.compact(),
24+
false,
25+
"Menu should not be compact after we set it to be not-compact."
26+
);
2527
}

crates/web-sys/tests/wasm/menu_item_element.rs

-43
This file was deleted.

crates/web-sys/webidls/enabled/HTMLMenuElement.webidl

+13-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
* and create derivative works of this document.
1313
*/
1414

15-
/* TODO
16-
interface MenuBuilder;
17-
*/
18-
19-
// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
15+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu
16+
// > The <menu> and <ul> elements both represent an unordered list of items.
17+
// > The key difference is that <ul> primarily contains items for display,
18+
// > while <menu> was intended for interactive items.
2019
[HTMLConstructor]
2120
interface HTMLMenuElement : HTMLElement {
21+
};
22+
23+
// > In early versions of the HTML specification, the <menu> element had
24+
// > an additional use case as a context menu. This functionality is considered
25+
// > obsolete and is not in the specification.
26+
// Define this as deprecated partial interface to prevent breaking changes
27+
// in wasm-bindgen.
28+
[RustDeprecated="Absent in all major browsers"]
29+
partial interface HTMLMenuElement {
2230
[CEReactions, SetterThrows]
2331
attribute DOMString type;
2432
[CEReactions, SetterThrows]

crates/web-sys/webidls/enabled/HTMLMenuItemElement.webidl

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
* and create derivative works of this document.
1212
*/
1313

14-
// http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element
15-
[HTMLConstructor]
14+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu
15+
// > The related <menuitem> element has been deprecated.
16+
// Keep this in wasm-bindgen to prevent breaking changes.
17+
[HTMLConstructor, RustDeprecated="Absent in all major browsers"]
1618
interface HTMLMenuItemElement : HTMLElement {
1719
[CEReactions, SetterThrows]
1820
attribute DOMString type;

0 commit comments

Comments
 (0)