Class CssSelectorMatcher

java.lang.Object
dev.jcputney.mjml.css.CssSelectorMatcher

public final class CssSelectorMatcher extends Object
Matches CSS selectors against HtmlElement nodes.

Supports all CSS2.1 selector types plus CSS3 attribute selectors. Pseudo-classes and pseudo-elements never match (they're preserved in style blocks, not inlined).

  • Method Details

    • matches

      public static boolean matches(CssSelector selector, HtmlElement element)
      Tests whether the given selector matches the given element.
      Parameters:
      selector - the CSS selector to test
      element - the HTML element to test against
      Returns:
      true if the selector matches the element
    • hasPseudo

      public static boolean hasPseudo(CssSelector selector)
      Returns true if the selector contains pseudo-classes or pseudo-elements that cannot be inlined (e.g. :hover, ::before).
      Parameters:
      selector - the CSS selector to check
      Returns:
      true if the selector contains any pseudo-class or pseudo-element