resolve regression related to equality of selectors

This commit is contained in:
ConnorSkees 2020-06-23 01:23:12 -04:00
parent 81aa6ee4b8
commit 991be977ac
4 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,7 @@ use codemap::Span;
use super::{ComplexSelector, CssMediaQuery, SimpleSelector};
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug)]
pub(crate) struct Extension {
/// The selector in which the `@extend` appeared.
pub extender: ComplexSelector,

View File

@ -55,7 +55,7 @@ impl Default for ExtendMode {
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug)]
pub(crate) struct Extender {
/// A map from all simple selectors in the stylesheet to the selector lists
/// that contain them.

View File

@ -2,7 +2,7 @@ use codemap::Span;
use crate::selector::Selector;
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug)]
pub(crate) struct ExtendRule {
pub selector: Selector,
pub is_optional: bool,

View File

@ -1,6 +1,7 @@
use std::{
collections::VecDeque,
fmt::{self, Write},
hash::{Hash, Hasher},
mem,
};
@ -18,7 +19,7 @@ use crate::{
///
/// A selector list is composed of `ComplexSelector`s. It matches an element
/// that matches any of the component selectors.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug)]
pub(crate) struct SelectorList {
/// The components of this selector.
///
@ -27,6 +28,20 @@ pub(crate) struct SelectorList {
pub span: Span,
}
impl PartialEq for SelectorList {
fn eq(&self, other: &SelectorList) -> bool {
self.components == other.components
}
}
impl Eq for SelectorList {}
impl Hash for SelectorList {
fn hash<H: Hasher>(&self, state: &mut H) {
self.components.hash(state);
}
}
impl fmt::Display for SelectorList {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let complexes = self.components.iter().filter(|c| !c.is_invisible());