diff options
Diffstat (limited to 'components/script/dom/cssrulelist.rs')
-rw-r--r-- | components/script/dom/cssrulelist.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 310a502df70..ac43335bbc8 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -144,14 +144,18 @@ impl CSSRuleList { RulesSource::Rules(ref css_rules) => { css_rules.write_with(&mut guard).remove_rule(index)?; let mut dom_rules = self.dom_rules.borrow_mut(); - dom_rules[index].get().map(|r| r.detach()); + if let Some(r) = dom_rules[index].get() { + r.detach() + } dom_rules.remove(index); Ok(()) }, RulesSource::Keyframes(ref kf) => { // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-deleterule let mut dom_rules = self.dom_rules.borrow_mut(); - dom_rules[index].get().map(|r| r.detach()); + if let Some(r) = dom_rules[index].get() { + r.detach() + } dom_rules.remove(index); kf.write_with(&mut guard).keyframes.remove(index); Ok(()) @@ -162,7 +166,9 @@ impl CSSRuleList { // Remove parent stylesheets from all children pub fn deparent_all(&self) { for rule in self.dom_rules.borrow().iter() { - rule.get().map(|r| DomRoot::upcast(r).deparent()); + if let Some(r) = rule.get() { + DomRoot::upcast(r).deparent() + } } } |