arsd.dom



T[] insertAfter(T)(T[] arr, int position, T[] what);
.

bool isInArray(T)(T item, T[] arr);
.

class Stack(T);
.

void push(T t);
.

T pop();
.

T peek();
.

bool empty();
.

T[] arr;
.

class ElementStream;
.

Element front();
.

this(Element start);
.

void popFront();
.

void currentKilled();
.

bool empty();
.

struct Current;
.

Current current;
.

Stack!(Current) stack;
.

bool isEmpty;
.

string[string] dup(in string[string] arr);
.

class Element;
.

Element[] children;
.

string tagName;
.

string[string] attributes;
.

bool selfClosed;
.

Document parentDocument;
.

this(Document _parentDocument, string _tagName, string[string] _attributes = null, bool _selfClosed = false);
.

@property Element previousSibling(string tagName = null);
.

@property Element nextSibling(string tagName = null);
.

@property CssStyle computedStyle();
.

@property Element cloned();
.

@property Element firstChild();
Returns the first child of this element. If it has no children, returns null.

this(string _tagName, string[string] _attributes = null);
Convenience constructor when you don't care about the parentDocument. Note this might break things on the document. Note also that without a parent document, elements are always in strict, case-sensitive mode.

Element appendChild(Element e);
Appends the given element to this one. The given element must not have a parent already.

Element insertBefore(Element where, Element what);
Inserts the second element to this node, right before the first param

Element insertAfter(Element where, Element what);
.

Element addChild(string tagName, string childInfo = null, string childInfo2 = null);
convenience function to quickly add a tag with some text or other relevant info (for example, it's a src for an element instead of inner text)

Element addChild(string tagName, Element firstChild);
.

T getParent(T)(string tagName = null);
.

Element swapNode(Element child, Element replacement);
swaps one child for a new thing. Returns the old child which is now parentless.

Element getElementById(string id);
.

SomeElementType requireElementById(SomeElementType = Element)(string id);
.

SomeElementType requireSelector(SomeElementType = Element)(string selector);
.

Element querySelector(string selector);
.

Element[] querySelectorAll(string selector);
a more standards-compliant alias for getElementsBySelector

Element[] getElementsBySelector(string selector);
.

Element[] getElementsByTagName(string tag);
.

Element appendText(string text);
.

@property Element[] childElements();
.

Element[] appendHtml(string html);
Appends the given html to the element, returning the elements appended

Element addClass(string c);
.

Element removeClass(string c);
.

bool hasClass(string c);
.

void reparent(Element newParent);
.

void insertChildAfter(Element child, Element where);
.

Element[] stealChildren(Element e, Element position = null);
.

Element prependChild(Element e);
Puts the current element first in our children list. The given element must not have a parent already.

string opDispatch(string name)(string v = null);
Provides easy access to attributes, like in javascript

const @property const(Element[]) childNodes();
Returns the element's children.

@property Element[] childNodes();
Mutable version of the same

const @property int nodeType();
.

const @property string innerHTML();
Returns a string containing all child elements, formatted such that it could be pasted into an XML file.

@property void innerHTML(string html);
Takes some html and replaces the element's children with the tree made from the string.

@property Element[] outerHTML(string html);
Replaces this node with the given html string, which is parsed

Note:
this invalidates the this reference, since it is removed from the tree.

Returns the new children that replace this.

@property string outerHTML();
.

@property void innerRawSource(string rawSource);
.

const string getAttribute(string name);
Gets the given attribute value, or null if the attribute is not set.

Note that the returned string is decoded, so it no longer contains any xml entities.

Element setAttribute(string name, string value);
Sets an attribute. Returns this for easy chaining

bool hasAttribute(string name);
Extension

void removeAttribute(string name);
Extension

const string className();
Gets the class attribute's contents. Returns an empty string if it has no class.

Element className(string c);
.

const string nodeValue();
.

Element replaceChild(Element find, Element replace);
.

Element removeChild(Element c);
Removes the given child from this list.

Returns the removed element.

Element[] removeChildren();
.

void replaceChild(Element find, Element[] replace);
EXTENSION

Replaces the given element with a whole group.

Element parentNode;
.

void stripOut();
Strips this tag out of the document, putting its inner html as children of the parent.

const string[] classNames();
INCOMPATIBLE -- extension

Splits the className into an array of each class given

const string firstInnerText();
Fetches the first consecutive text nodes, concatenated together

const @property string innerText();
Fetch the inside text, with all tags stripped out

@property void innerText(string text);
Sets the inside text, replacing all children

@property void outerText(string text);
Strips this node out of the document, replacing it with the given text

const @property string outerText();
Same result as innerText; the tag with all tags stripped out

const string toString();
Turns the whole element, including tag, attributes, and children, into a string which could be pasted into an XML file.

ElementStream tree();
Returns a lazy range of all its children, recursively.

class DocumentFragment: arsd.dom.Element;
.

this(Document _parentDocument);
.

const string toString();
.

string htmlEntitiesEncode(string data);
.

string xmlEntitiesEncode(string data);
.

dchar parseEntity(in dchar[] entity);
.

string htmlEntitiesDecode(string data, bool strict = false);
.

class RawSource: arsd.dom.Element;
.

this(Document _parentDocument, string s);
.

const string nodeValue();
.

const int nodeType();
.

const string toString();
.

Element appendChild(Element e);
.

string source;
.

enum NodeType;
.

class TextNode: arsd.dom.Element;
.

this(Document _parentDocument, string e);
.

static TextNode fromUndecodedString(Document _parentDocument, string html);
.

@property Element cloned();
.

const string nodeValue();
.

const int nodeType();
.

const string toString();
.

Element appendChild(Element e);
.

string contents;
.

class Link: arsd.dom.Element;
There are subclasses of Element offering improved helper functions for the element in HTML. .

this(Document _parentDocument);
.

this(string href, string text);
.

string getValue(string name);
This gets a variable from the URL's query string.

void updateQueryString(string[string] vars);
.

void setValue(string name, string variable);
Sets or adds the variable with the given name to the given value It automatically URI encodes the values and takes care of the ? and &.

void removeValue(string name);
Removes the given variable from the query string

class Form: arsd.dom.Element;
.

this(Document _parentDocument);
.

void setValue(string field, string value, bool makeNew = true);
Set's the form field's value. For input boxes, this sets the value attribute. For textareas, it sets the innerText. For radio boxes and select boxes, it removes the checked/selected attribute from all, and adds it to the one matching the value. For checkboxes, if the value is non-null and not empty, it checks the box. If you set a value that doesn't exist, it throws an exception if makeNew is false. Otherwise, it makes a new input with type=hidden to keep the value.

string getValue(string field);
Gets the value of the field; what would be given if it submitted right now. (so it handles select boxes and radio buttons too). For checkboxes, if a value isn't given, but it is checked, it returns "checked", since null and "" are indistinguishable

string getPostableData();
.

Element[] getField(string name);
Gets the actual elements with the given name

Element getLabel(string forId);
Grabs the
Element addField(string name, string value, string type = "hidden");
Adds a new INPUT field to the end of the form with the given attributes.

void removeField(string name);
Removes the given field from the form. It finds the element and knocks it right out.

class Table: arsd.dom.Element;
.

this(Document _parentDocument);
.

Element th(T)(T t);
.

Element td(T)(T t);
.

Element appendRow(T...)(T t);
.

Element captionElement();
.

@property string caption();
.

@property void caption(string text);
.

class MarkupError: object.Exception;
.

this(string message);
.

class ElementNotFoundException: object.Exception;
.

this(string type, string search);
.

struct Html;
The html struct is used to differentiate between regular text nodes and html in certain functions

string source;
.

class Document;
.

this(string data, bool caseSensitive = false, bool strict = false);
.

this();
Creates an empty document. It has *nothing* in it at all.

void parse(string data, bool caseSensitive = false, bool strict = false);
Concatenates any consecutive text nodes

Take XMLish* data and try to make the DOM tree out of it.

The goal isn't to be perfect, but to just be good enough to approximate Javascript's behavior.

If strict, it throws on something that doesn't make sense. (Examples: mismatched tags. It doesn't validate!) If not strict, it tries to recover anyway, and only throws when something is REALLY unworkable.

If strict is false, it uses a magic list of tags that needn't be closed. If you are writing a document specifically for this, try to avoid such - use self closed tags at least. Easier to parse.

The xml version at the top really shouldn't be there...

@property string title();
.

@property void title(string t);
.

Element getElementById(string id);
.

SomeElementType requireElementById(SomeElementType = Element)(string id);
.

SomeElementType requireSelector(SomeElementType = Element)(string selector);
.

Element querySelector(string selector);
.

Element[] querySelectorAll(string selector);
.

Element[] getElementsBySelector(string selector);
.

Element[] getElementsByTagName(string tag);
.

Element getFirstElementByTagName(string tag);
Extension:


FIXME:
btw, this could just be a lazy range......

Element mainBody();
.

string getMeta(string name);
this uses a weird thing... it's [name=] if no colon and [property=] if colon

void setMeta(string name, string value);
.

Form[] forms();
.

Form createForm();
.

Element createElement(string name);
.

Element createFragment();
.

Element createTextNode(string content);
.

Element findFirst(bool delegate(Element) doesItMatch);
.

void clear();
.

void setProlog(string d);
.

string prolog;
.

const string toString();
.

Element root;
.

bool loose;
.

int intFromHex(string hex);
.

static immutable string[] selectorTokens;
.

int idToken(string str, int position);
.

string[] lexSelector(string selector);
.

struct SelectorPart;
.

string tagNameFilter;
.

string[] attributesPresent;
[attr]

string[2u][] attributesEqual;
[attr=value]

string[2u][] attributesStartsWith;
[attr^=value]

string[2u][] attributesEndsWith;
[attr$=value]

string[2u][] attributesIncludesSeparatedBySpaces;
[attr~=value]

string[2u][] attributesIncludesSeparatedByDashes;
[attr|=value]

string[2u][] attributesInclude;
[attr*=value]

string[2u][] attributesNotEqual;
[attr!=value] -- extension by me

bool firstChild;
.

bool lastChild;
.

bool emptyElement;
.

bool oddChild;
.

bool evenChild;
.

bool rootElement;
.

int separation;
-1 == only itself; the null selector, 0 == tree, 1 == childNodes, 2 == childAfter, 3 == youngerSibling, 4 == parentOf

string toString();
.

bool matchElement(Element e);
.

Element[] getElementsBySelectorParts(Element start, SelectorPart[] parts);
.

struct Selector;
.

SelectorPart[] parts;
.

string toString();
.

Element[] getElements(Element start);
.

bool matchElement(Element e, Element relativeTo = null);
If relativeTo == null, it assumes the root of the parent document.

static Selector fromString(string selector);
.

Selector[] parseSelectorString(string selector);
.

Selector parseSelector(string[] tokens);
.

Element[] removeDuplicates(Element[] input);
.

string unCamelCase(string a);
.

string camelCase(string a);
.

class CssStyle;
.

this(string rule, string content);
.

Specificity getSpecificityOfRule(string rule);
.

string originatingRule;
.

Specificity originatingSpecificity;
.

union Specificity;
.

uint score;
.

ubyte tags;
.

ubyte classes;
.

ubyte ids;
.

ubyte important;
0 = none, 1 = stylesheet author, 2 = inline style, 3 = user important .

struct Property;
.

bool givenExplicitly;
this is false if for example the user said "padding" and this is "padding-left"

string name;
.

string value;
.

Specificity specificity;
.

Property[] properties;
.

string opDispatch(string nameGiven)(string value = null);
.

string getValue(string name);
takes dash style name

string setValue(string name, string value, Specificity newSpecificity, bool explicit = true);
takes dash style name

void expandShortForm(Property p, Specificity specificity);
.

string toString();
.

class StyleSheet;
.

CssStyle[] rules;
.

this(string source);
.

void apply(Document document);
.


Page generated by Ddoc.