lexborisov / Modest

Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies.
GNU Lesser General Public License v2.1
732 stars 65 forks source link

New CSS selector ":contains(text)" #42

Closed f34nk closed 6 years ago

f34nk commented 6 years ago

Hey Alex, I followed your instructions in #36 and added new pseudo class "contains".

As of now, the selector argument cannot contain single or double quotation marks. That's because I basically duplicated the implementation from pseudo class "has", so behavior and serialization is the same.

Example:

const char *selector = ":contains(Hello)"; // works
const char *selector = ":contains('Hello')"; // Bad Selector
const char *selector = ":contains(\"Hello\")"; // Bad Selector

According to the spec (from 2001) however, quotation marks should also be supported.

The :contains("foo") pseudo-class notation represents an element whose textual contents contain the given substring. The argument of this pseudo-class can be a string (surrounded by double quotes) or a keyword.

So my implementation only solves the "argument as keyword" case. Tell me what you think.

Best, Frank

lexborisov commented 6 years ago

AWESOME!

f34nk commented 6 years ago

Thanks man! That was fun :)

lexborisov commented 6 years ago

You're welcome! 😄