Skip to content

Commit e37a1dd

Browse files
authored
Add MathMLElement and HTMLOrSVGElement bindings (#4143)
1 parent 9593300 commit e37a1dd

18 files changed

+1534
-80
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
## Unreleased
55

6+
### Added
7+
8+
* Added support for the [`HTMLOrSVGElement`](https://html.spec.whatwg.org/#htmlorsvgelement) `mixin`, which is used for all interfaces deriving from `Element`.
9+
[#4143](https://github.com/rustwasm/wasm-bindgen/pull/4143)
10+
11+
* Added bindings for [MathMLElement](https://www.w3.org/TR/MathML3).
12+
[#4143](https://github.com/rustwasm/wasm-bindgen/pull/4143)
13+
614
### Changed
715

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

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

1627
* Fixed methods with `self: &Self` consuming the object.

crates/web-sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ LockManager = []
790790
LockManagerSnapshot = []
791791
LockMode = []
792792
LockOptions = []
793+
MathMlElement = ["Element", "EventTarget", "Node"]
793794
MediaCapabilities = []
794795
MediaCapabilitiesInfo = []
795796
MediaConfiguration = []

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

+6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ extern "C" {
1818
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/autofocus)"]
1919
#[doc = ""]
2020
#[doc = "*This API requires the following crate features to be activated: `HtmlButtonElement`*"]
21+
#[deprecated(
22+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
23+
)]
2124
pub fn autofocus(this: &HtmlButtonElement) -> bool;
2225
# [wasm_bindgen (structural , method , setter , js_class = "HTMLButtonElement" , js_name = autofocus)]
2326
#[doc = "Setter for the `autofocus` field of this object."]
2427
#[doc = ""]
2528
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/autofocus)"]
2629
#[doc = ""]
2730
#[doc = "*This API requires the following crate features to be activated: `HtmlButtonElement`*"]
31+
#[deprecated(
32+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
33+
)]
2834
pub fn set_autofocus(this: &HtmlButtonElement, value: bool);
2935
# [wasm_bindgen (structural , method , getter , js_class = "HTMLButtonElement" , js_name = disabled)]
3036
#[doc = "Getter for the `disabled` field of this object."]

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

+58-30
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ extern "C" {
8282
#[doc = ""]
8383
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
8484
pub fn set_dir(this: &HtmlElement, value: &str);
85-
#[cfg(feature = "DomStringMap")]
86-
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = dataset)]
87-
#[doc = "Getter for the `dataset` field of this object."]
88-
#[doc = ""]
89-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset)"]
90-
#[doc = ""]
91-
#[doc = "*This API requires the following crate features to be activated: `DomStringMap`, `HtmlElement`*"]
92-
pub fn dataset(this: &HtmlElement) -> DomStringMap;
9385
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = innerText)]
9486
#[doc = "Getter for the `innerText` field of this object."]
9587
#[doc = ""]
@@ -132,20 +124,6 @@ extern "C" {
132124
#[doc = ""]
133125
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
134126
pub fn set_inert(this: &HtmlElement, value: bool);
135-
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = tabIndex)]
136-
#[doc = "Getter for the `tabIndex` field of this object."]
137-
#[doc = ""]
138-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
139-
#[doc = ""]
140-
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
141-
pub fn tab_index(this: &HtmlElement) -> i32;
142-
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = tabIndex)]
143-
#[doc = "Setter for the `tabIndex` field of this object."]
144-
#[doc = ""]
145-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
146-
#[doc = ""]
147-
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
148-
pub fn set_tab_index(this: &HtmlElement, value: i32);
149127
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = accessKey)]
150128
#[doc = "Getter for the `accessKey` field of this object."]
151129
#[doc = ""]
@@ -230,14 +208,6 @@ extern "C" {
230208
#[doc = ""]
231209
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
232210
pub fn set_spellcheck(this: &HtmlElement, value: bool);
233-
#[cfg(feature = "CssStyleDeclaration")]
234-
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = style)]
235-
#[doc = "Getter for the `style` field of this object."]
236-
#[doc = ""]
237-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)"]
238-
#[doc = ""]
239-
#[doc = "*This API requires the following crate features to be activated: `CssStyleDeclaration`, `HtmlElement`*"]
240-
pub fn style(this: &HtmlElement) -> CssStyleDeclaration;
241211
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = offsetParent)]
242212
#[doc = "Getter for the `offsetParent` field of this object."]
243213
#[doc = ""]
@@ -315,6 +285,14 @@ extern "C" {
315285
#[doc = ""]
316286
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
317287
pub fn set_onpaste(this: &HtmlElement, value: Option<&::js_sys::Function>);
288+
#[cfg(feature = "CssStyleDeclaration")]
289+
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = style)]
290+
#[doc = "Getter for the `style` field of this object."]
291+
#[doc = ""]
292+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style)"]
293+
#[doc = ""]
294+
#[doc = "*This API requires the following crate features to be activated: `CssStyleDeclaration`, `HtmlElement`*"]
295+
pub fn style(this: &HtmlElement) -> CssStyleDeclaration;
318296
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = onabort)]
319297
#[doc = "Getter for the `onabort` field of this object."]
320298
#[doc = ""]
@@ -1477,6 +1455,56 @@ extern "C" {
14771455
#[doc = ""]
14781456
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
14791457
pub fn set_onwebkittransitionend(this: &HtmlElement, value: Option<&::js_sys::Function>);
1458+
#[cfg(feature = "DomStringMap")]
1459+
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = dataset)]
1460+
#[doc = "Getter for the `dataset` field of this object."]
1461+
#[doc = ""]
1462+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset)"]
1463+
#[doc = ""]
1464+
#[doc = "*This API requires the following crate features to be activated: `DomStringMap`, `HtmlElement`*"]
1465+
pub fn dataset(this: &HtmlElement) -> DomStringMap;
1466+
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = nonce)]
1467+
#[doc = "Getter for the `nonce` field of this object."]
1468+
#[doc = ""]
1469+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce)"]
1470+
#[doc = ""]
1471+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1472+
pub fn nonce(this: &HtmlElement) -> String;
1473+
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = nonce)]
1474+
#[doc = "Setter for the `nonce` field of this object."]
1475+
#[doc = ""]
1476+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce)"]
1477+
#[doc = ""]
1478+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1479+
pub fn set_nonce(this: &HtmlElement, value: &str);
1480+
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = autofocus)]
1481+
#[doc = "Getter for the `autofocus` field of this object."]
1482+
#[doc = ""]
1483+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autofocus)"]
1484+
#[doc = ""]
1485+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1486+
pub fn autofocus(this: &HtmlElement) -> bool;
1487+
# [wasm_bindgen (structural , catch , method , setter , js_class = "HTMLElement" , js_name = autofocus)]
1488+
#[doc = "Setter for the `autofocus` field of this object."]
1489+
#[doc = ""]
1490+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/autofocus)"]
1491+
#[doc = ""]
1492+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1493+
pub fn set_autofocus(this: &HtmlElement, value: bool) -> Result<(), JsValue>;
1494+
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = tabIndex)]
1495+
#[doc = "Getter for the `tabIndex` field of this object."]
1496+
#[doc = ""]
1497+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
1498+
#[doc = ""]
1499+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1500+
pub fn tab_index(this: &HtmlElement) -> i32;
1501+
# [wasm_bindgen (structural , method , setter , js_class = "HTMLElement" , js_name = tabIndex)]
1502+
#[doc = "Setter for the `tabIndex` field of this object."]
1503+
#[doc = ""]
1504+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)"]
1505+
#[doc = ""]
1506+
#[doc = "*This API requires the following crate features to be activated: `HtmlElement`*"]
1507+
pub fn set_tab_index(this: &HtmlElement, value: i32);
14801508
# [wasm_bindgen (structural , method , getter , js_class = "HTMLElement" , js_name = onerror)]
14811509
#[doc = "Getter for the `onerror` field of this object."]
14821510
#[doc = ""]

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

+6
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,19 @@ extern "C" {
6060
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autofocus)"]
6161
#[doc = ""]
6262
#[doc = "*This API requires the following crate features to be activated: `HtmlInputElement`*"]
63+
#[deprecated(
64+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
65+
)]
6366
pub fn autofocus(this: &HtmlInputElement) -> bool;
6467
# [wasm_bindgen (structural , method , setter , js_class = "HTMLInputElement" , js_name = autofocus)]
6568
#[doc = "Setter for the `autofocus` field of this object."]
6669
#[doc = ""]
6770
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/autofocus)"]
6871
#[doc = ""]
6972
#[doc = "*This API requires the following crate features to be activated: `HtmlInputElement`*"]
73+
#[deprecated(
74+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
75+
)]
7076
pub fn set_autofocus(this: &HtmlInputElement, value: bool);
7177
# [wasm_bindgen (structural , method , getter , js_class = "HTMLInputElement" , js_name = defaultChecked)]
7278
#[doc = "Getter for the `defaultChecked` field of this object."]

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

+6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ extern "C" {
1818
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/autofocus)"]
1919
#[doc = ""]
2020
#[doc = "*This API requires the following crate features to be activated: `HtmlSelectElement`*"]
21+
#[deprecated(
22+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
23+
)]
2124
pub fn autofocus(this: &HtmlSelectElement) -> bool;
2225
# [wasm_bindgen (structural , method , setter , js_class = "HTMLSelectElement" , js_name = autofocus)]
2326
#[doc = "Setter for the `autofocus` field of this object."]
2427
#[doc = ""]
2528
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/autofocus)"]
2629
#[doc = ""]
2730
#[doc = "*This API requires the following crate features to be activated: `HtmlSelectElement`*"]
31+
#[deprecated(
32+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
33+
)]
2834
pub fn set_autofocus(this: &HtmlSelectElement, value: bool);
2935
# [wasm_bindgen (structural , method , getter , js_class = "HTMLSelectElement" , js_name = autocomplete)]
3036
#[doc = "Getter for the `autocomplete` field of this object."]

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

+6
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ extern "C" {
3232
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/autofocus)"]
3333
#[doc = ""]
3434
#[doc = "*This API requires the following crate features to be activated: `HtmlTextAreaElement`*"]
35+
#[deprecated(
36+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
37+
)]
3538
pub fn autofocus(this: &HtmlTextAreaElement) -> bool;
3639
# [wasm_bindgen (structural , method , setter , js_class = "HTMLTextAreaElement" , js_name = autofocus)]
3740
#[doc = "Setter for the `autofocus` field of this object."]
3841
#[doc = ""]
3942
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/autofocus)"]
4043
#[doc = ""]
4144
#[doc = "*This API requires the following crate features to be activated: `HtmlTextAreaElement`*"]
45+
#[deprecated(
46+
note = "Use `HtmlElement::autofocus()` or `HtmlElement::set_autofocus()` instead."
47+
)]
4248
pub fn set_autofocus(this: &HtmlTextAreaElement, value: bool);
4349
# [wasm_bindgen (structural , method , getter , js_class = "HTMLTextAreaElement" , js_name = cols)]
4450
#[doc = "Getter for the `cols` field of this object."]

0 commit comments

Comments
 (0)