Skip to content

Commit

Permalink
Get rid of unnecessary unsafes
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Dec 8, 2018
1 parent bf41952 commit 8fe17fb
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/webapi/document.rs
Expand Up @@ -127,21 +127,17 @@ impl Document {
/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/Document/title)
// https://html.spec.whatwg.org/#the-document-object:document.title
pub fn title( &self ) -> String {
unsafe {
js!(
return @{self}.title;
).try_into().unwrap()
}
js!(
return @{self}.title;
).try_into().unwrap()
}

/// Sets the title of the document.
///
/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/Document/title)
// https://html.spec.whatwg.org/#the-document-object:document.title
pub fn set_title( &self, title: &str ) {
unsafe {
js!( @(no_return) @{self}.title = @{title}; );
}
js!( @(no_return) @{self}.title = @{title}; );
}

/// Returns the Element that is the root element of the document (for example, the `<html>`
Expand All @@ -150,11 +146,9 @@ impl Document {
/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement)
// https://dom.spec.whatwg.org/#ref-for-dom-document-documentelement
pub fn document_element( &self ) -> Option< Element > {
unsafe {
js!(
return @{self}.documentElement;
).try_into().unwrap()
}
js!(
return @{self}.documentElement;
).try_into().unwrap()
}

/// Returns the Element that the pointer is locked to, if it is locked to any
Expand Down

0 comments on commit 8fe17fb

Please sign in to comment.