From 81aa6ee4b864fcbe15d5153970a4dcfe31744c5d Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 23 Jun 2020 01:11:10 -0400 Subject: [PATCH] fix how equality is resolved between pseudo selectors --- src/selector/simple.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/selector/simple.rs b/src/selector/simple.rs index 90a7bff..bcb6a5d 100644 --- a/src/selector/simple.rs +++ b/src/selector/simple.rs @@ -1,4 +1,7 @@ -use std::fmt::{self, Write}; +use std::{ + fmt::{self, Write}, + hash::{Hash, Hasher}, +}; use codemap::Span; @@ -375,7 +378,7 @@ impl SimpleSelector { } } -#[derive(Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug)] pub(crate) struct Pseudo { /// The name of this selector. pub name: String, @@ -412,6 +415,30 @@ pub(crate) struct Pseudo { pub span: Span, } +impl PartialEq for Pseudo { + fn eq(&self, other: &Pseudo) -> bool { + self.name == other.name + && self.normalized_name == other.normalized_name + && self.is_class == other.is_class + && self.is_syntactic_class == other.is_syntactic_class + && self.argument == other.argument + && self.selector == other.selector + } +} + +impl Eq for Pseudo {} + +impl Hash for Pseudo { + fn hash(&self, state: &mut H) { + self.name.hash(state); + self.normalized_name.hash(state); + self.is_class.hash(state); + self.is_syntactic_class.hash(state); + self.argument.hash(state); + self.selector.hash(state); + } +} + impl fmt::Display for Pseudo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(sel) = &self.selector {