fix how equality is resolved between pseudo selectors

This commit is contained in:
ConnorSkees 2020-06-23 01:11:10 -04:00
parent c700845174
commit 81aa6ee4b8

View File

@ -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<H: Hasher>(&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 {