aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/virtualmethods.rs
diff options
context:
space:
mode:
authorZack Slayton <zack.slayton@gmail.com>2015-03-08 18:55:52 -0400
committerZack Slayton <zack.slayton@gmail.com>2015-03-10 09:18:55 -0400
commit08ac0766eda2340008642e86799ea2cb1ef6e59f (patch)
treee53ed9f42ff9fa45603fa04ec0d772430ee7fd1e /components/script/dom/virtualmethods.rs
parent09c36de8f1db54fdd2514f4b66c3a3753719a1bb (diff)
downloadservo-08ac0766eda2340008642e86799ea2cb1ef6e59f.tar.gz
servo-08ac0766eda2340008642e86799ea2cb1ef6e59f.zip
Use new `if let` syntax wherever possible. Fixes #4153.
Diffstat (limited to 'components/script/dom/virtualmethods.rs')
-rw-r--r--components/script/dom/virtualmethods.rs37
1 files changed, 14 insertions, 23 deletions
diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs
index 707298ebdc5..a3e53f42bd3 100644
--- a/components/script/dom/virtualmethods.rs
+++ b/components/script/dom/virtualmethods.rs
@@ -71,18 +71,16 @@ pub trait VirtualMethods {
/// Called when changing or adding attributes, after the attribute's value
/// has been updated.
fn after_set_attr(&self, attr: JSRef<Attr>) {
- match self.super_type() {
- Some(ref s) => s.after_set_attr(attr),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.after_set_attr(attr);
}
}
/// Called when changing or removing attributes, before any modification
/// has taken place.
fn before_remove_attr(&self, attr: JSRef<Attr>) {
- match self.super_type() {
- Some(ref s) => s.before_remove_attr(attr),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.before_remove_attr(attr);
}
}
@@ -98,45 +96,38 @@ pub trait VirtualMethods {
/// Called when a Node is appended to a tree, where 'tree_in_doc' indicates
/// whether the tree is part of a Document.
fn bind_to_tree(&self, tree_in_doc: bool) {
- match self.super_type() {
- Some(ref s) => s.bind_to_tree(tree_in_doc),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.bind_to_tree(tree_in_doc);
}
}
/// Called when a Node is removed from a tree, where 'tree_in_doc'
/// indicates whether the tree is part of a Document.
fn unbind_from_tree(&self, tree_in_doc: bool) {
- match self.super_type() {
- Some(ref s) => s.unbind_from_tree(tree_in_doc),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.unbind_from_tree(tree_in_doc);
}
}
/// Called on the parent when a node is added to its child list.
fn child_inserted(&self, child: JSRef<Node>) {
- match self.super_type() {
- Some(ref s) => s.child_inserted(child),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.child_inserted(child);
}
}
/// Called during event dispatch after the bubbling phase completes.
fn handle_event(&self, event: JSRef<Event>) {
- match self.super_type() {
- Some(s) => {
- s.handle_event(event);
- }
- _ => (),
+ if let Some(s) = self.super_type() {
+ s.handle_event(event);
}
}
/// https://dom.spec.whatwg.org/#concept-node-clone (step 5)
fn cloning_steps(&self, copy: JSRef<Node>, maybe_doc: Option<JSRef<Document>>,
clone_children: CloneChildrenFlag) {
- match self.super_type() {
- Some(ref s) => s.cloning_steps(copy, maybe_doc, clone_children),
- _ => (),
+ if let Some(ref s) = self.super_type() {
+ s.cloning_steps(copy, maybe_doc, clone_children);
}
}
}