1 use webcore::reference_type::ReferenceType;
2 use webapi::element::Element;
3 
4 /// The `INonElementParentNode` mixin contains methods and properties
5 /// that are common to `Document` and `DocumentFragment`.
6 ///
7 /// You most likely don't want to `use` this directly; instead
8 /// you should `use stdweb::traits::*;`.
9 // https://dom.spec.whatwg.org/#nonelementparentnode
10 pub trait INonElementParentNode: ReferenceType {
11     /// Returns a reference to the element by its ID; the ID is a string which can
12     /// be used to uniquely identify the element, found in the HTML `id` attribute.
13     ///
14     /// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById)
15     // https://dom.spec.whatwg.org/#ref-for-dom-nonelementparentnode-getelementbyid
get_element_by_id( &self, id: &str ) -> Option< Element >16     fn get_element_by_id( &self, id: &str ) -> Option< Element > {
17         unsafe {
18             js!( return @{self.as_ref()}.getElementById( @{id} ); ).into_reference_unchecked()
19         }
20     }
21 }
22