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

Use if let in HTMLTableElement::SetCaption. #6291

Merged
merged 1 commit into from Jun 6, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use if let in HTMLTableElement::SetCaption.

  • Loading branch information
Ms2ger committed Jun 6, 2015
commit 57f575b5ca62fab1bce80eea7061f59fdd5586da
@@ -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());
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.