Skip to content

Commit

Permalink
Merge pull request #577 from jaytaph/root-fix
Browse files Browse the repository at this point in the history
Never match when there is no syntax
  • Loading branch information
jaytaph authored Aug 31, 2024
2 parents c4bf40e + 865a8fb commit f76828e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/gosub_styling/src/syntax_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ impl CssSyntaxTree {

/// Matches a CSS value (or set of values) against the syntax tree. Will return a normalized version of the value(s) if it matches.
pub fn matches(&self, input: &[CssValue]) -> bool {
if self.components.is_empty() {
return false;
}

if self.components.len() != 1 {
panic!("Syntax tree must have exactly one root component");
}
Expand All @@ -46,6 +50,10 @@ impl CssSyntaxTree {
}

pub fn matches_and_shorthands(&self, input: &[CssValue], resolver: ShorthandResolver) -> bool {
if self.components.is_empty() {
return false;
}

if self.components.len() != 1 {
panic!("Syntax tree must have exactly one root component");
}
Expand Down

0 comments on commit f76828e

Please sign in to comment.