diff --git a/src/document/css/apply.c b/src/document/css/apply.c index 0397bb38..b419c878 100644 --- a/src/document/css/apply.c +++ b/src/document/css/apply.c @@ -189,10 +189,20 @@ examine_element(struct html_context *html_context, struct css_selector *base, code = get_attr_val(element->options, "class", html_context->options); if (code && seltype <= CST_CLASS) { - selector = find_css_selector(selectors, CST_CLASS, rel, code, -1); - process_found_selector(selector, CST_CLASS, base); + unsigned char *class = code; + + while (class) { + unsigned char *end = strchr(class, ' '); + + if (end) + *end++ = 0; + + selector = find_css_selector(selectors, CST_CLASS, rel, class, -1); + process_found_selector(selector, CST_CLASS, base); + class = end; + } } - if (code) mem_free(code); + mem_free_if(code); code = get_attr_val(element->options, "id", html_context->options); if (code && seltype <= CST_ID) { diff --git a/test/css/selectors.html b/test/css/selectors.html index ed618086..cec3aecf 100644 --- a/test/css/selectors.html +++ b/test/css/selectors.html @@ -2,6 +2,7 @@ div { color: yellow } div#foo { background: red } div.foo { background: blue } + div.bar { color: red } div .foo{ background: purple } p,span { color: aqua; } div, { background: green; } @@ -14,5 +15,6 @@
p i bold i
jedi mind tricks