Skip to content

Commit

Permalink
Add MathMLElement and HTMLOrSVGElement bindings (#4143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M authored Oct 15, 2024
1 parent 9593300 commit e37a1dd
Show file tree
Hide file tree
Showing 18 changed files with 1,534 additions and 80 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

## Unreleased

### Added

* Added support for the [`HTMLOrSVGElement`](https://html.spec.whatwg.org/#htmlorsvgelement) `mixin`, which is used for all interfaces deriving from `Element`.
[#4143](https://github.com/rustwasm/wasm-bindgen/pull/4143)

* Added bindings for [MathMLElement](https://www.w3.org/TR/MathML3).
[#4143](https://github.com/rustwasm/wasm-bindgen/pull/4143)

### Changed

* String enums now generate private TypeScript types but only if used.
Expand All @@ -11,6 +19,9 @@
* Remove unnecessary JSDoc type annotations from generated `.d.ts` files
[#4187](https://github.com/rustwasm/wasm-bindgen/pull/4187)

* Deprecate `autofocus`, `tabIndex`, `focus()` and `blur()` bindings in favor of bindings on the inherited `Element` class.
[#4143](https://github.com/rustwasm/wasm-bindgen/pull/4143)

### Fixed

* Fixed methods with `self: &Self` consuming the object.
Expand Down
1 change: 1 addition & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ LockManager = []
LockManagerSnapshot = []
LockMode = []
LockOptions = []
MathMlElement = ["Element", "EventTarget", "Node"]
MediaCapabilities = []
MediaCapabilitiesInfo = []
MediaConfiguration = []
Expand Down
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/gen_HtmlButtonElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlButtonElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn autofocus(this: &HtmlButtonElement) -> bool;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLButtonElement" , js_name = autofocus)]
#[doc = "Setter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlButtonElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn set_autofocus(this: &HtmlButtonElement, value: bool);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLButtonElement" , js_name = disabled)]
#[doc = "Getter for the `disabled` field of this object."]
Expand Down
88 changes: 58 additions & 30 deletions crates/web-sys/src/features/gen_HtmlElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_dir(this: &HtmlElement, value: &str);
#[cfg(feature = "DomStringMap")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = dataset)]
#[doc = "Getter for the `dataset` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomStringMap`, `HtmlElement`*"]
pub fn dataset(this: &HtmlElement) -> DomStringMap;
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = innerText)]
#[doc = "Getter for the `innerText` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -132,20 +124,6 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_inert(this: &HtmlElement, value: bool);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = tabIndex)]
#[doc = "Getter for the `tabIndex` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn tab_index(this: &HtmlElement) -> i32;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = tabIndex)]
#[doc = "Setter for the `tabIndex` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_tab_index(this: &HtmlElement, value: i32);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = accessKey)]
#[doc = "Getter for the `accessKey` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -230,14 +208,6 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_spellcheck(this: &HtmlElement, value: bool);
#[cfg(feature = "CssStyleDeclaration")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = style)]
#[doc = "Getter for the `style` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssStyleDeclaration`, `HtmlElement`*"]
pub fn style(this: &HtmlElement) -> CssStyleDeclaration;
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = offsetParent)]
#[doc = "Getter for the `offsetParent` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -315,6 +285,14 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_onpaste(this: &HtmlElement, value: Option<&::js_sys::Function>);
#[cfg(feature = "CssStyleDeclaration")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = style)]
#[doc = "Getter for the `style` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssStyleDeclaration`, `HtmlElement`*"]
pub fn style(this: &HtmlElement) -> CssStyleDeclaration;
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = onabort)]
#[doc = "Getter for the `onabort` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -1477,6 +1455,56 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_onwebkittransitionend(this: &HtmlElement, value: Option<&::js_sys::Function>);
#[cfg(feature = "DomStringMap")]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = dataset)]
#[doc = "Getter for the `dataset` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomStringMap`, `HtmlElement`*"]
pub fn dataset(this: &HtmlElement) -> DomStringMap;
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = nonce)]
#[doc = "Getter for the `nonce` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn nonce(this: &HtmlElement) -> String;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = nonce)]
#[doc = "Setter for the `nonce` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_nonce(this: &HtmlElement, value: &str);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = autofocus)]
#[doc = "Getter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn autofocus(this: &HtmlElement) -> bool;
# [wasm_bindgen (structural , catch , method , setter , js_class = "HTMLElement" , js_name = autofocus)]
#[doc = "Setter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_autofocus(this: &HtmlElement, value: bool) -> Result<(), JsValue>;
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = tabIndex)]
#[doc = "Getter for the `tabIndex` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn tab_index(this: &HtmlElement) -> i32;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = tabIndex)]
#[doc = "Setter for the `tabIndex` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
pub fn set_tab_index(this: &HtmlElement, value: i32);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = onerror)]
#[doc = "Getter for the `onerror` field of this object."]
#[doc = ""]
Expand Down
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/gen_HtmlInputElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlInputElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn autofocus(this: &HtmlInputElement) -> bool;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLInputElement" , js_name = autofocus)]
#[doc = "Setter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlInputElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn set_autofocus(this: &HtmlInputElement, value: bool);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLInputElement" , js_name = defaultChecked)]
#[doc = "Getter for the `defaultChecked` field of this object."]
Expand Down
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/gen_HtmlSelectElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlSelectElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn autofocus(this: &HtmlSelectElement) -> bool;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLSelectElement" , js_name = autofocus)]
#[doc = "Setter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlSelectElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn set_autofocus(this: &HtmlSelectElement, value: bool);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLSelectElement" , js_name = autocomplete)]
#[doc = "Getter for the `autocomplete` field of this object."]
Expand Down
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/gen_HtmlTextAreaElement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlTextAreaElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn autofocus(this: &HtmlTextAreaElement) -> bool;
# [wasm_bindgen (structural , method , setter , js_class = "HTMLTextAreaElement" , js_name = autofocus)]
#[doc = "Setter for the `autofocus` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/autofocus)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlTextAreaElement`*"]
#[deprecated(
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
)]
pub fn set_autofocus(this: &HtmlTextAreaElement, value: bool);
# [wasm_bindgen (structural , method , getter , js_class = "HTMLTextAreaElement" , js_name = cols)]
#[doc = "Getter for the `cols` field of this object."]
Expand Down
Loading

0 comments on commit e37a1dd

Please sign in to comment.