Skip to content

Commit

Permalink
wasm_bindgen(method) is only for extern types
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Dec 5, 2024
1 parent 3184fb2 commit 37969ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion js-api/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl_mutations!(Comment);

#[wasm_bindgen]
impl Comment {
#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn text(&self) -> JsResult<String> {
self.0.get().map(|c| c.text())
}
Expand Down
6 changes: 3 additions & 3 deletions js-api/src/doctype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ impl_from_native!(NativeDoctype --> Doctype);

#[wasm_bindgen]
impl Doctype {
#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn name(&self) -> JsResult<Option<String>> {
self.0.get().map(|d| d.name())
}

#[wasm_bindgen(method, getter=publicId)]
#[wasm_bindgen(getter=publicId)]
pub fn public_id(&self) -> JsResult<Option<String>> {
self.0.get().map(|d| d.public_id())
}

#[wasm_bindgen(method, getter=systemId)]
#[wasm_bindgen(getter=systemId)]
pub fn system_id(&self) -> JsResult<Option<String>> {
self.0.get().map(|d| d.system_id())
}
Expand Down
20 changes: 10 additions & 10 deletions js-api/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ impl_mutations!(Element);

#[wasm_bindgen]
impl Element {
#[wasm_bindgen(method, getter=tagName)]
#[wasm_bindgen(getter=tagName)]
pub fn tag_name(&self) -> JsResult<String> {
self.0.get().map(|e| e.tag_name())
}

#[wasm_bindgen(method, setter=tagName)]
#[wasm_bindgen(setter=tagName)]
pub fn set_tag_name(&mut self, name: &str) -> JsResult<()> {
self.0.get_mut()?.set_tag_name(name).into_js_result()
}

#[wasm_bindgen(method, getter=namespaceURI)]
#[wasm_bindgen(getter=namespaceURI)]
pub fn namespace_uri(&self) -> JsResult<JsValue> {
self.0.get().map(|e| e.namespace_uri().into())
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn attributes(&self) -> JsResult<JsValue> {
self.0
.get()
Expand All @@ -54,25 +54,25 @@ impl Element {
.and_then(|a| to_js_value(&a).into_js_result())
}

#[wasm_bindgen(method, js_name=getAttribute)]
#[wasm_bindgen(js_name=getAttribute)]
pub fn get_attribute(&self, name: &str) -> JsResult<Option<String>> {
self.0.get().map(|e| e.get_attribute(name))
}

#[wasm_bindgen(method, js_name=hasAttribute)]
#[wasm_bindgen(js_name=hasAttribute)]
pub fn has_attribute(&self, name: &str) -> JsResult<bool> {
self.0.get().map(|e| e.has_attribute(name))
}

#[wasm_bindgen(method, js_name=setAttribute)]
#[wasm_bindgen(js_name=setAttribute)]
pub fn set_attribute(&mut self, name: &str, value: &str) -> JsResult<()> {
self.0
.get_mut()?
.set_attribute(name, value)
.into_js_result()
}

#[wasm_bindgen(method, js_name=removeAttribute)]
#[wasm_bindgen(js_name=removeAttribute)]
pub fn remove_attribute(&mut self, name: &str) -> JsResult<()> {
self.0.get_mut().map(|e| e.remove_attribute(name))
}
Expand All @@ -97,7 +97,7 @@ impl Element {
.map(|e| e.append(content, content_type.into_native()))
}

#[wasm_bindgen(method, js_name=setInnerContent)]
#[wasm_bindgen(js_name=setInnerContent)]
pub fn set_inner_content(
&mut self,
content: &str,
Expand All @@ -108,7 +108,7 @@ impl Element {
.map(|e| e.set_inner_content(content, content_type.into_native()))
}

#[wasm_bindgen(method, js_name=removeAndKeepContent)]
#[wasm_bindgen(js_name=removeAndKeepContent)]
pub fn remove_and_keep_content(&mut self) -> Result<(), JsValue> {
self.0.get_mut().map(|e| e.remove_and_keep_content())
}
Expand Down
2 changes: 1 addition & 1 deletion js-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ macro_rules! impl_mutations {
self.0.get_mut().map(|o| o.remove())
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn removed(&self) -> JsResult<bool> {
self.0.get().map(|o| o.removed())
}
Expand Down
4 changes: 2 additions & 2 deletions js-api/src/text_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ impl_mutations!(TextChunk);

#[wasm_bindgen]
impl TextChunk {
#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn text(&self) -> JsResult<String> {
self.0.get().map(|c| c.as_str().into())
}

#[wasm_bindgen(method, getter=lastInTextNode)]
#[wasm_bindgen(getter=lastInTextNode)]
pub fn last_in_text_node(&self) -> JsResult<bool> {
self.0.get().map(|c| c.last_in_text_node())
}
Expand Down

0 comments on commit 37969ff

Please sign in to comment.