Commit 66adb8c9 authored by jan.koester's avatar jan.koester
Browse files

combinator fixed

parent a345e063
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -281,9 +281,17 @@ namespace {
    std::vector<std::string> splitCombinatorChain(const std::string &selector) {
        std::vector<std::string> parts;
        std::string cur;
        int bracketDepth = 0;
        for (char c : selector) {
            if (c == ' ' || c == '\t' || c == '\n' || c == '\r' ||
                c == '>' || c == '+' || c == '~') {
            if (c == '[') ++bracketDepth;
            else if (c == ']' && bracketDepth > 0) --bracketDepth;

            // Inside "[...]", '~' (and '+'/'>') are attribute-operator
            // characters (e.g. "[rel~=external]"), not combinators -- only
            // split on them outside of brackets, same bracket-awareness
            // stripAttributeSelectors already needs for its own scan.
            bool isCombinatorChar = (c == '>' || c == '+' || c == '~') && bracketDepth == 0;
            if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || isCombinatorChar) {
                if (!cur.empty()) { parts.push_back(cur); cur.clear(); }
            } else {
                cur += c;