Skip to content
CSS library for D
D
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/css
.editorconfig
.gitignore
LICENSE
README.md
dub.json

README.md

cssd

CSS library for D

The library currently includes a non-validating parser module and a DOM agnostic (currently through an element proxy template) selector matching module The selector matching module currently implements all CSS3 and the case-insensitive attribute matching from CSS4. Pseudo-elements are currently left to be handled by the user code to minimize the proxy template interface.

Example handler:

struct CSSOMBuilder {
	void onSelector(const(char)[] data) {}
	void onSelectorEnd() {}
	void onBlockEnd() {}
	void onPropertyName(const(char)[] data) {}
	void onPropertyValue(const(char)[] data) {}
	void onPropertyValueEnd() {}
	void onComment(const(char)[] data) {}
}

Example usage:

auto builder = CSSOMBuilder();
parseCSS(`h1:hover > span#highlight { background: black; }`, builder);

Example selector usage:

	auto highlightSelector = Selector.parse("h1:hover > span#highlight"); // parses selector into a representation that is fast to test
	if (highlightSelector.matches(someElement))
		someElement.attr("style", highlightStyle);
You can’t perform that action at this time.