diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-06-05 12:06:24 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-06-06 13:19:00 +0200 |
commit | 57f575b5ca62fab1bce80eea7061f59fdd5586da (patch) | |
tree | 19a8ebfecf7c0f45f3d73c2e0f448eed4207d940 /components/script/dom/htmltableelement.rs | |
parent | ad5846f2e14ac15aca9f561975ae9476d0f13244 (diff) | |
download | servo-57f575b5ca62fab1bce80eea7061f59fdd5586da.tar.gz servo-57f575b5ca62fab1bce80eea7061f59fdd5586da.zip |
Use if let in HTMLTableElement::SetCaption.
Diffstat (limited to 'components/script/dom/htmltableelement.rs')
-rw-r--r-- | components/script/dom/htmltableelement.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index a32c3e7e452..0f254f07ad6 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCaptionElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast}; -use dom::bindings::js::{JSRef, Rootable, Temporary}; +use dom::bindings::js::{JSRef, Rootable, Temporary, OptionalRootable, RootedReference}; use dom::document::Document; use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::element::ElementTypeId; @@ -79,21 +79,14 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> { // https://www.whatwg.org/html/#dom-table-caption fn SetCaption(self, new_caption: Option<JSRef<HTMLTableCaptionElement>>) { let node: JSRef<Node> = NodeCast::from_ref(self); - let old_caption = self.GetCaption(); - match old_caption { - Some(htmlelem) => { - let htmlelem_root = htmlelem.root(); - let old_caption_node: JSRef<Node> = NodeCast::from_ref(htmlelem_root.r()); - assert!(node.RemoveChild(old_caption_node).is_ok()); - } - None => () + if let Some(ref caption) = self.GetCaption().root() { + assert!(node.RemoveChild(NodeCast::from_ref(caption.r())).is_ok()); } - new_caption.map(|caption| { - let new_caption_node: JSRef<Node> = NodeCast::from_ref(caption); - assert!(node.AppendChild(new_caption_node).is_ok()); - }); + if let Some(caption) = new_caption { + assert!(node.AppendChild(NodeCast::from_ref(caption)).is_ok()); + } } } |