The OpenD Programming Language

Document.opIndex

This is just something I'm toying with. Right now, you use opIndex to put in css selectors. It returns a struct that forwards calls to all elements it holds, and returns itself so you can chain it.

class Document
opIndex
(
string selector
)

Examples

document["p"].innerText("hello").addClass("modified");

Equivalent to: foreach(e; document.getElementsBySelector("p")) { e.innerText("hello"); e.addClas("modified"); }

Note: always use function calls (not property syntax) and don't use toString in there for best results.

You can also do things like: document["p"]["b"] though tbh I'm not sure why since the selector string can do all that anyway. Maybe you could put in some kind of custom filter function tho.

Meta