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

Inconsistency with HtmlSelectElement::remove between rust and javascript version #1111

Closed
rgiot opened this issue Dec 13, 2018 · 1 comment
Closed

Comments

@rgiot
Copy link

rgiot commented Dec 13, 2018

I'm not a Javascript expert, so I do not really know the idiom to empty a select tag and this issue may be a nonsense.

Naively I have used this code by following web_sys documentation:

document
	.get_element_by_id("xxx")
	.unwrap()
	.dyn_ref::<HtmlSelectElement>()
	.unwrap()
	.remove();

But it did not emptied at all my select. Is is a correct behavior ?

Digging deeper in the documentations, I have noticed an inconsistency between web_sys signature of HtmlSelectElement::remove
https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.HtmlSelectElement.html#method.remove
and javascript one
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/remove

The first one does not take any argument, whereas the second one expect one index.

As a workaround, I used this code that works:

document
	.get_element_by_id("taxonomy-application-choice")
	.expect("Unable to get taxonomy-application-choice")
	.dyn_ref::<Element>()
	.unwrap()
	.set_inner_html("");
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Dec 14, 2018
First commented out in rustwasm#568 when we didn't support this we now do!

Closes rustwasm#1111
@alexcrichton
Copy link
Contributor

Oops definitely a mistake!

I've opened a fix in #1113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants