Commit d5f1ec88 authored by jan.koester's avatar jan.koester
Browse files

testt

parent 66adb8c9
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -308,6 +308,42 @@ int main(){
        }
    }

    // --- getCSSRules with a bare "[attr~=value]" selector on the target
    // itself (no class/tag/id qualifier) -- real bug found importing a
    // page-builder site: splitCombinatorChain scanned raw selector text for
    // combinator characters (' ', '>', '+', '~') without skipping "[...]"
    // contents, so the '~' inside "~=" was mistaken for a sibling
    // combinator and split "[data-kit-frame~=solid]" into two bogus
    // compounds -- silently dropping every declaration behind a "~="
    // attribute selector site-wide (e.g. every "solid frame" card lost its
    // background-color, leaving a page-level backdrop showing through as a
    // solid black gap where a white card should have been). ---
    std::cout << "=== getCSSRules with a bare [attr~=value] selector ===" << std::endl;
    {
        std::string html =
            "<html><head>"
            "<style>[data-kit-frame~=solid]{background-color:red}</style>"
            "</head><body>"
            "<div id=\"card\" data-kit-frame=\"solid\">hi</div>"
            "</body></html>";

        libhtmlpp::HtmlString htmlString(html);
        libhtmlpp::Element &root = htmlString.parse();

        libhtmlpp::CSSStyleSheet sheet;
        libhtmlpp::collectStyleBlocks(sheet, root);

        libhtmlpp::HtmlElement *card = static_cast<libhtmlpp::HtmlElement*>(&root)->getElementbyID("card");
        check(card != nullptr, "found target element by id");

        if (card) {
            std::set<std::string> seen;
            auto result = libhtmlpp::getCSSRules(*card, sheet, seen);
            check(result.properties["background-color"] == "red",
                  "bare [attr~=value] selector (no class/tag/id) matches the target element");
        }
    }

    // --- resolveCSSVariables ---
    std::cout << "=== resolveCSSVariables ===" << std::endl;
    {