Selector::replace takes super selector by reference

This commit is contained in:
ConnorSkees 2020-04-06 14:40:28 -04:00
parent 26fdcfdf17
commit 47330a92c6
3 changed files with 6 additions and 6 deletions

View File

@ -106,7 +106,7 @@ impl AtRule {
AtRuleKind::Annotation => todo!("@annotation not yet implemented"), AtRuleKind::Annotation => todo!("@annotation not yet implemented"),
AtRuleKind::AtRoot => { AtRuleKind::AtRoot => {
let mut selector = &Selector::replace( let mut selector = &Selector::replace(
super_selector.clone(), super_selector,
Selector::from_tokens( Selector::from_tokens(
&mut read_until_open_curly_brace(toks).into_iter().peekable(), &mut read_until_open_curly_brace(toks).into_iter().peekable(),
scope, scope,
@ -127,7 +127,7 @@ impl AtRule {
let raw_stmts = eat_stmts_at_root( let raw_stmts = eat_stmts_at_root(
&mut body.into_iter().peekable(), &mut body.into_iter().peekable(),
scope, scope,
&selector, selector,
0, 0,
is_some, is_some,
)? )?

View File

@ -58,7 +58,7 @@ pub(crate) fn eat_stmts_at_root<I: Iterator<Item = Token>>(
if nesting > 1 || is_some { if nesting > 1 || is_some {
selector = super_selector.zip(&selector); selector = super_selector.zip(&selector);
} else { } else {
selector = Selector::replace(super_selector.clone(), selector); selector = Selector::replace(super_selector, selector);
} }
nesting += 1; nesting += 1;
let rules = eat_stmts_at_root(toks, scope, &selector, nesting, true)?; let rules = eat_stmts_at_root(toks, scope, &selector, nesting, true)?;

View File

@ -374,7 +374,7 @@ impl Selector {
} }
} }
pub fn replace(super_selector: Selector, this: Selector) -> Selector { pub fn replace(super_selector: &Selector, this: Selector) -> Selector {
if super_selector.0.is_empty() || this.0.is_empty() { if super_selector.0.is_empty() || this.0.is_empty() {
return this; return this;
} }
@ -397,7 +397,7 @@ impl Selector {
found_inner = true; found_inner = true;
kinds.push(SelectorKind::PseudoParen( kinds.push(SelectorKind::PseudoParen(
name, name,
Selector::replace(super_selector.clone(), inner), Selector::replace(super_selector, inner),
)) ))
} else { } else {
kinds.push(SelectorKind::PseudoParen(name, inner)); kinds.push(SelectorKind::PseudoParen(name, inner));
@ -445,7 +445,7 @@ impl Selector {
found_inner = true; found_inner = true;
this_selector.push(SelectorKind::PseudoParen( this_selector.push(SelectorKind::PseudoParen(
s, s,
Selector::replace(self.clone(), inner_selector), Selector::replace(self, inner_selector),
)) ))
} else { } else {
this_selector.push(SelectorKind::PseudoParen(s, inner_selector)); this_selector.push(SelectorKind::PseudoParen(s, inner_selector));