Skip to content
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

Deprecate HtmlMenuItemElement and parts of HtmlMenuElement #3448

Merged
merged 1 commit into from
May 23, 2023
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
15 changes: 15 additions & 0 deletions crates/web-sys/src/features/gen_HtmlMenuItemElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,113 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
#[deprecated(note = "Absent in all major browsers")]
pub type HtmlMenuItemElement;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = type)]
#[doc = "Getter for the `type` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/type)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn type_(this: &HtmlMenuItemElement) -> String;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = type)]
#[doc = "Setter for the `type` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/type)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_type(this: &HtmlMenuItemElement, value: &str);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = label)]
#[doc = "Getter for the `label` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/label)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn label(this: &HtmlMenuItemElement) -> String;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = label)]
#[doc = "Setter for the `label` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/label)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_label(this: &HtmlMenuItemElement, value: &str);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = icon)]
#[doc = "Getter for the `icon` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/icon)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn icon(this: &HtmlMenuItemElement) -> String;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = icon)]
#[doc = "Setter for the `icon` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/icon)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_icon(this: &HtmlMenuItemElement, value: &str);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = disabled)]
#[doc = "Getter for the `disabled` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/disabled)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn disabled(this: &HtmlMenuItemElement) -> bool;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = disabled)]
#[doc = "Setter for the `disabled` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/disabled)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_disabled(this: &HtmlMenuItemElement, value: bool);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = checked)]
#[doc = "Getter for the `checked` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/checked)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn checked(this: &HtmlMenuItemElement) -> bool;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = checked)]
#[doc = "Setter for the `checked` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/checked)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_checked(this: &HtmlMenuItemElement, value: bool);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)]
#[doc = "Getter for the `radiogroup` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/radiogroup)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn radiogroup(this: &HtmlMenuItemElement) -> String;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = radiogroup)]
#[doc = "Setter for the `radiogroup` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/radiogroup)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn set_radiogroup(this: &HtmlMenuItemElement, value: &str);
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)]
#[doc = "Getter for the `defaultChecked` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuItemElement/defaultChecked)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlMenuItemElement`*"]
pub fn default_checked(this: &HtmlMenuItemElement) -> bool;
#[deprecated(note = "Absent in all major browsers")]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLMenuItemElement" , js_name = defaultChecked)]
#[doc = "Setter for the `defaultChecked` field of this object."]
#[doc = ""]
Expand Down
8 changes: 0 additions & 8 deletions crates/web-sys/tests/wasm/html_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ fn test_html_element() {
);
assert!(element.is_content_editable(), "Should be content_editable");

/*TODO doesn't work in Chrome
// TODO verify case where menu is passed
match element.context_menu() {
None => assert!(true, "Shouldn't have a custom menu set"),
_ => assert!(false, "Shouldn't have a custom menu set")
};
*/

// TODO: This test is also broken in Chrome (but not Firefox).
// assert!(!element.spellcheck(), "Shouldn't be spellchecked");
element.set_spellcheck(true);
Expand Down
8 changes: 3 additions & 5 deletions crates/web-sys/tests/wasm/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod br_element;
pub mod button_element;
pub mod console;
pub mod div_element;
pub mod dom_point;
pub mod element;
pub mod event;
pub mod head_element;
Expand All @@ -21,13 +22,10 @@ pub mod hr_element;
pub mod html_element;
pub mod html_html_element;
pub mod image_data;
pub mod input_element;
//TODO: Both menu-related tests completely break in Chrome, but run fine in Firefox.
//pub mod menu_element;
//pub mod menu_item_element;
pub mod dom_point;
pub mod indexeddb;
pub mod input_element;
pub mod location;
pub mod menu_element;
pub mod meta_element;
pub mod meter_element;
pub mod mod_elements;
Expand Down
20 changes: 11 additions & 9 deletions crates/web-sys/tests/wasm/menu_element.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use wasm_bindgen_test::*;
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::HtmlMenuElement;

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

menu.set_type("toolbar");
assert_eq!(menu.type_(), "toolbar", "Menu should have the type value we gave it.");

menu.set_label("Menu label here");
assert_eq!(menu.label(), "Menu label here", "Menu should have the label value we gave it.");

menu.set_compact(true);
assert_eq!(menu.compact(), true, "Menu should be compact after we set it to be compact.");
assert_eq!(
menu.compact(),
true,
"Menu should be compact after we set it to be compact."
);

menu.set_compact(false);
assert_eq!(menu.compact(), false, "Menu should not be compact after we set it to be not-compact.");
assert_eq!(
menu.compact(),
false,
"Menu should not be compact after we set it to be not-compact."
);
}
43 changes: 0 additions & 43 deletions crates/web-sys/tests/wasm/menu_item_element.rs

This file was deleted.

18 changes: 13 additions & 5 deletions crates/web-sys/webidls/enabled/HTMLMenuElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@
* and create derivative works of this document.
*/

/* TODO
interface MenuBuilder;
*/

// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu
// > The <menu> and <ul> elements both represent an unordered list of items.
// > The key difference is that <ul> primarily contains items for display,
// > while <menu> was intended for interactive items.
[HTMLConstructor]
interface HTMLMenuElement : HTMLElement {
};

// > In early versions of the HTML specification, the <menu> element had
// > an additional use case as a context menu. This functionality is considered
// > obsolete and is not in the specification.
// Define this as deprecated partial interface to prevent breaking changes
// in wasm-bindgen.
[RustDeprecated="Absent in all major browsers"]
partial interface HTMLMenuElement {
[CEReactions, SetterThrows]
attribute DOMString type;
[CEReactions, SetterThrows]
Expand Down
6 changes: 4 additions & 2 deletions crates/web-sys/webidls/enabled/HTMLMenuItemElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* and create derivative works of this document.
*/

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