arsd.dom
This is an html DOM implementation, started with cloning what the browser offers in Javascript, but going well beyond it in convenience. If you can do it in Javascript, you can probably do it with this module. And much more. Note:some of the documentation here writes html with added spaces. That's because ddoc doesn't bother encoding html output, and adding spaces is easier than using LT macros everywhere. BTW:
this file depends on arsd.characterencodings, so help it correctly read files from the internet. You should be able to get characterencodings.d from the same place you got this file.
Class / struct Name | Description | ||
---|---|---|---|
CssStyle | This is probably not useful to you unless you're writing a browser or something like that. It represents a *computed* style, like what the browser gives you after applying stylesheets, inline styles, and html attributes. From here, you can start to make a layout engine for the box model and have a css aware browser. | ||
DataSet | A proxy object to do the Element class' dataset property. See Element.dataset for more info. | ||
Document | The main document interface, including a html parser. | ||
DocumentFragment | . | ||
Element | This represents almost everything in the DOM. | ||
ElementNotFoundException | This is used when you are using one of the require variants of navigation, and no matching element can be found in the tree. | ||
ElementStream | This is the lazy range that walks the tree for you. It tries to go in the lexical order of the source: node, then children from first to last, each recursively. | ||
ElementStyle | for style, i want to be able to set it with a string like a plain attribute, but also be able to do properties Javascript style. | ||
Event | This is a DOM event, like in javascript. Note that this library never fires events - it is only here for you to use if you want it. | ||
Form | . | ||
Html | The html struct is used to differentiate between regular text nodes and html in certain functions | ||
Link | There are subclasses of Element offering improved helper functions for the element in HTML. . | ||
MarkupError | . | ||
RawSource | . | ||
Selector | . | ||
SelectorPart | . | ||
Stack | This is kinda private; just a little utility container for use by the ElementStream class. | ||
StyleSheet | This probably isn't useful, unless you're writing a browser or something like that. You might want to look at arsd.html for css macro, nesting, etc., or just use standard css as text. | ||
Table | . | ||
TableCell | Represents anything that can be a table cell - | or | html.
|
TableRow | Represents a table row element - a | ||
TextNode | . | ||
XmlDocument | Specializes Document for handling generic XML. (always uses strict mode, uses xml mime type and file header) |
Enum Name | Description |
---|---|
NodeType | . |
Function Name | Description |
---|---|
EventHandler | used for DOM events |
FileResource | This might belong in another module, but it represents a file with a mime type and some data. Document implements this interface with type = text/html (see Document.contentType for more info) and data = document.toString, so you can return Documents anywhere web.d expects FileResources. |
camelCase | Translates a css style property-name to a camel cased propertyName |
getElementsBySelectorParts | . |
htmlEntitiesDecode | This takes a string of raw HTML and decodes the entities into a nice D utf-8 string. By default, it uses loose mode - it will try to return a useful string from garbage input too. Set the second parameter to true if you'd prefer it to strictly throw exceptions on garbage input. |
htmlEntitiesEncode | Given text, encode all html entities on it - &, <, >, and ". This function also encodes all 8 bit characters as entities, thus ensuring the resultant text will work even if your charset isn't set right. |
idToken | . |
intFromHex | . |
lexSelector | . |
parseEntity | This helper function is used for decoding html entities. It has a hard-coded list of entities and characters. |
parseSelector | . |
parseSelectorString | . |
removeDuplicates | . |
require | You can use this to do an easy null check or a dynamic cast+null check on any element. |
selectorTokens | . |
unCamelCase | Converts a camel cased propertyName to a css style dashed property-name |
xmlEntitiesEncode | An alias for htmlEntitiesEncode; it works for xml too |
- This might belong in another module, but it represents a file with a mime type and some data.
Document implements this interface with type = text/html (see Document.contentType for more info)
and data = document.toString, so you can return Documents anywhere web.d expects FileResources.
Member Quick Reference Member Name Description contentType the content-type of the file. e.g. "text/html; charset=utf-8" or "image/png" getData the data - the content-type of the file. e.g. "text/html; charset=utf-8" or "image/png"
- the data
- A proxy object to do the Element class' dataset property. See Element.dataset for more info. Do not create this object directly.
- for style, i want to be able to set it with a string like a plain attribute, but also be able to do properties Javascript style.
- .
- You can use this to do an easy null check or a dynamic cast+null check on any element.
- This represents almost everything in the DOM.
Member Quick Reference Member Name Description addChild . addChildren Convenience function to append text intermixed with other children. For example: div.addChildren("You can visit my website by ", new Link("mysite.com", "clicking here"), "."); or div.addChildren("Hello, ", user.name, "!"); See also: appendHtml. This might be a bit simpler though because you don't have to think about escaping. addClass Adds a string to the class attribute. The class attribute is used a lot in CSS. addSibling Another convenience function. Adds a child directly after the current one, returning the new child. appendChild Appends the given element to this one. The given element must not have a parent already. appendChildren . appendHtml Appends the given html to the element, returning the elements appended appendText . attributes This is where the attributes are actually stored. You should use getAttribute, setAttribute, and hasAttribute instead. childElements . childNodes Mutable version of the same className . classNames Splits the className into an array of each class given classes get all the classes on this element cloneNode Clones the node. If deepClone is true, clone all inner tags too. If false, only do this tag (and its attributes), but it will have no contents. cloned This is a full clone of the element computedStyle . dataset HTML5's dataset property. It is an alternate view into attributes with the data- prefix. directText Sets the direct text, keeping the same place. firstChild Returns the first child of this element. If it has no children, returns null. Remember, text nodes are children too. firstInnerText Fetches the first consecutive nodes, if text nodes, concatenated together getAttribute Gets the given attribute value, or null if the attribute is not set. getElementById . getElementsByClassName . getElementsBySelector Does a CSS selector getElementsByTagName . getParent Gets the nearest node, going up the chain, with the given tagName May return null or throw. hasAttribute Returns if the attribute exists. hasClass Returns whether the given class appears in this element. innerHTML Takes some html and replaces the element's children with the tree made from the string. innerRawSource This sets the inner content of the element *without* trying to parse it. You can inject any code in there; this serves as an escape hatch from the dom. innerText Fetch the inside text, with all tags stripped out. insertAfter . insertBefore Inserts the second element to this node, right before the first param insertChildAfter . lastChild make Convenience function to try to do the right thing for HTML. This is the main way I create elements. nextSibling . nodeType . nodeValue . opDispatch Provides easy access to attributes, object style. outerHTML Replaces this node with the given html string, which is parsed outerText Strips this node out of the document, replacing it with the given text parentDocument Get the parent Document object that contains this element. It may be null, so remember to check for that. parentNode . prependChild Puts the current element first in our children list. The given element must not have a parent already. previousSibling . querySelector Note:
you can give multiple selectors, separated by commas. It will return the first match it finds.querySelectorAll a more standards-compliant alias for getElementsBySelector removeAllChildren Removes all inner content from the tag; all child text and elements are gone. removeAttribute Removes the given attribute from the element. removeChild Removes the given child from this list. removeChildren This removes all the children from this element, returning the old list. removeClass Removes a particular class name. removeFromTree shorthand for this.parentNode.removeChild(this) with parentNode null check if the element already isn't in a tree, it does nothing. reparent . replaceChild Replaces the given element with a whole group. replaceWith Replaces this element with something else in the tree. requireElementById . requireSelector . setAttribute Sets an attribute. Returns this for easy chaining stealChildren . stripOut Strips this tag out of the document, putting its inner html as children of the parent. style This sets the style attribute with a string. swapNode swaps one child for a new thing. Returns the old child which is now parentless. tagName The name of the tag. Remember, changing this doesn't change the dynamic type of the object. toString Turns the whole element, including tag, attributes, and children, into a string which could be pasted into an XML file. tree Returns a lazy range of all its children, recursively. wrapIn Wraps this element inside the given element. It's like this.replaceWith(what); what.appendchild(this); writeToAppender This is the actual implementation used by toString. You can pass it a preallocated buffer to save some time. Returns the string it creates. - The name of the tag. Remember, changing this doesn't change the dynamic type of the object.
- This is where the attributes are actually stored. You should use getAttribute, setAttribute, and hasAttribute instead.
- Get the parent Document object that contains this element. It may be null, so remember to check for that.
- .
- Convenience function to try to do the right thing for HTML. This is the main way I create elements.
- this(Document _parentDocument, string _tagName, string[string] _attributes = null, bool _selfClosed = false);
- Generally, you don't want to call this yourself - use Element.make or document.createElement instead.
- 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.
- Returns the first child of this element. If it has no children, returns null. Remember, text nodes are children too.
- .
- .
- Gets the nearest node, going up the chain, with the given tagName May return null or throw.
- .
- .
- .
- Note:
you can give multiple selectors, separated by commas. It will return the first match it finds. - a more standards-compliant alias for getElementsBySelector
- Does a CSS selector
-- all, default if nothing else is there
tag#id.class.class.class:pseudo[attrib=what][attrib=what] OP selector
It is all additive
OP
space = descendant
> = direct descendant
+ = sibling (E+F Matches any F element immediately preceded by a sibling element E)
[foo] Foo is present as an attribute
[foo="warning"] Matches any E element whose "foo" attribute value is exactly equal to "warning".
E[foo~="warning"] Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning"
E[lang|="en"] Matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en".
[item$=sdas] ends with
[item^-sdsad] begins with
Quotes are optional here.
Pseudos:
:first-child :last-child :link (same as a[href] for our purposes here) There can be commas separating the selector. A comma separated list result is OR'd onto the main. This ONLY cares about elements. text, etc, are ignored There should be two functions: given element, does it match the selector? and given a selector, give me all the elements - .
- .
- 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.
- Sets an attribute. Returns this for easy chaining
- Returns if the attribute exists.
- Removes the given attribute from the element.
- Gets the class attribute's contents. Returns an empty string if it has no class.
- .
- Provides easy access to attributes, object style. auto element = Element.make("a"); a.href = "cool.html"; // this is the same as a.setAttribute("href", "cool.html"); string where = a.href; // same as a.getAttribute("href");
- Returns the element's children.
- Mutable version of the same
- get all the classes on this element
- Adds a string to the class attribute. The class attribute is used a lot in CSS.
- Removes a particular class name.
- Returns whether the given class appears in this element.
- HTML5's dataset property. It is an alternate view into attributes with the data- prefix.
Given:
We get: assert(a.dataset.myProperty == "cool"); - Provides both string and object style (like in Javascript) access to the style attribute.
- This sets the style attribute with a string.
- .
- Removes all inner content from the tag; all child text and elements are gone.
- 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)
- Another convenience function. Adds a child directly after the current one, returning the new child. Between this, addChild, and parentNode, you can build a tree as a single expression.
- Convenience function to append text intermixed with other children. For example: div.addChildren("You can visit my website by ", new Link("mysite.com", "clicking here"), "."); or div.addChildren("Hello, ", user.name, "!"); See also: appendHtml. This might be a bit simpler though because you don't have to think about escaping.
- .
- Appends the given element to this one. The given element must not have a parent already.
- .
- Inserts the second element to this node, right before the first param
- .
- swaps one child for a new thing. Returns the old child which is now parentless.
- .
- .
- Appends the given html to the element, returning the elements appended
- .
- .
- .
- Puts the current element first in our children list. The given element must not have a parent already.
- Returns a string containing all child elements, formatted such that it could be pasted into an XML file.
- Takes some html and replaces the element's children with the tree made from the string.
- 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. - Returns all the html for this element, including the tag itself. This is equivalent to calling toString().
- This sets the inner content of the element *without* trying to parse it. You can inject any code in there; this serves as an escape hatch from the dom. The only times you might actually need it are for < style > and < script > tags in html. Other than that, innerHTML and/or innerText should do the job.
- .
- Removes the given child from this list. Returns the removed element.
- This removes all the children from this element, returning the old list.
- Replaces the given element with a whole group.
- Strips this tag out of the document, putting its inner html
as children of the parent.
For example, given:
hello there
, if you call stripOut() on the b element, you'll be left withhello there
. The idea here is to make it easy to get rid of garbage markup you aren't interested in.
- shorthand for this.parentNode.removeChild(this) with parentNode null check if the element already isn't in a tree, it does nothing.
- Wraps this element inside the given element.
It's like this.replaceWith(what); what.appendchild(this);
Given:
< b >cool</ b >, if you call b.wrapIn(new Link("site.com", "my site is ")); you'll end up with: < a href="site.com">my site is < b >cool< /b ></ a >. - Replaces this element with something else in the tree.
- Splits the className into an array of each class given
- Fetches the first consecutive nodes, if text nodes, concatenated together If the first node is not text, returns null. See also: directText, innerText
- Fetch the inside text, with all tags stripped out.
cool api & code dude
- Sets the inside text, replacing all children. You don't have to worry about entity encoding.
- Returns the text directly under this element, not recursively like innerText. See also: firstInnerText
- Sets the direct text, keeping the same place. Unlike innerText, this does *not* remove existing elements in the element. It only replaces the first text node it sees. If there are no text nodes, it calls appendText So, given (ignore the spaces in the tags): < div > < img > text here < /div > it will keep the img, and replace the "text here".
- Strips this node out of the document, replacing it with the given text
- Same result as innerText; the tag with all inner tags stripped out
- This is a full clone of the element
- Clones the node. If deepClone is true, clone all inner tags too. If false, only do this tag (and its attributes), but it will have no contents.
- .
- .
- Turns the whole element, including tag, attributes, and children, into a string which could be pasted into an XML file.
- This is the actual implementation used by toString. You can pass it a preallocated buffer to save some time. Returns the string it creates.
- Returns a lazy range of all its children, recursively.
- .
Member Quick Reference Member Name Description writeToAppender . - this(Document _parentDocument);
- .
- .
- Given text, encode all html entities on it - &, <, >, and ". This function also encodes all 8 bit characters as entities, thus ensuring the resultant text will work even if your charset isn't set right. The output parameter can be given to append to an existing buffer. You don't have to pass one; regardless, the return value will be usable for you, with just the data encoded.
- An alias for htmlEntitiesEncode; it works for xml too
- This helper function is used for decoding html entities. It has a hard-coded list of entities and characters.
- This takes a string of raw HTML and decodes the entities into a nice D utf-8 string. By default, it uses loose mode - it will try to return a useful string from garbage input too. Set the second parameter to true if you'd prefer it to strictly throw exceptions on garbage input.
- .
Member Quick Reference Member Name Description appendChild . nodeType . nodeValue . source . writeToAppender . - this(Document _parentDocument, string s);
- .
- .
- .
- .
- .
- .
- .
Member Quick Reference Member Name Description appendChild . cloned . contents . fromUndecodedString . nodeType . nodeValue . writeToAppender . - this(Document _parentDocument, string e);
- .
- .
- .
- .
- .
- .
- .
- .
- There are subclasses of Element offering improved helper
functions for the element in HTML.
.
Member Quick Reference Member Name Description getValue This gets a variable from the URL's query string. removeValue Removes the given variable from the query string setValue 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 &. updateQueryString . - this(Document _parentDocument);
- .
- this(string href, string text);
- .
- This gets a variable from the URL's query string.
- .
- 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 &.
- Removes the given variable from the query string
- .
Member Quick Reference Member Name Description addField Adds a new INPUT field to the end of the form with the given attributes. addValueArray This takes an array of strings and adds hidden elements for each one of them. Unlike setValue, it makes no attempt to find and modify existing elements in the form to the new values. getField Gets the actual elements with the given name getLabel Grabs the getPostableData . getValue 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 removeField Removes the given field from the form. It finds the element and knocks it right out. setValue 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. - this(Document _parentDocument);
- .
- 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.
- This takes an array of strings and adds hidden elements for each one of them. Unlike setValue, it makes no attempt to find and modify existing elements in the form to the new values.
- 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
- .
- Gets the actual elements with the given name
- Grabs the
- Adds a new INPUT field to the end of the form with the given attributes.
- Removes the given field from the form. It finds the element and knocks it right out.
- .
Member Quick Reference Member Name Description appendRow . caption . captionElement . , or portion if you pass one. Note:getGrid Gets the logical layout of the table as a rectangular grid of cells. It considers rowspan and colspan. A cell with a large span is represented in the grid by being referenced several times. The tablePortition parameter can get just a ,
the rectangular grid might include null cells. This is kinda expensive so you should call once when you want the grid, then do lookups on the returned array.td . th . - this(Document _parentDocument);
- .
- .
- .
- .
- .
- .
- .
- Gets the logical layout of the table as a rectangular grid of
cells. It considers rowspan and colspan. A cell with a large
span is represented in the grid by being referenced several times.
The tablePortition parameter can get just a , , or
portion if you pass one.
Note:
the rectangular grid might include null cells. This is kinda expensive so you should call once when you want the grid, then do lookups on the returned array.
- Represents a table row element - a
- this(Document _parentDocument);
- .
- Represents anything that can be a table cell -
or html. - this(Document _parentDocument, string _tagName);
- .
- .
- this(string message);
- .
- This is used when you are using one of the require variants of navigation, and no matching element can be found in the tree.
- this(string type, string search, string file = __FILE__, int line = __LINE__);
- type == kind of element you were looking for and search == a selector describing the search.
- The html struct is used to differentiate between regular text nodes and html in certain functions
Easiest way to construct it is like this: auto html = Html("
hello
");Member Quick Reference Member Name Description source This string holds the actual html. Use it to retrieve the contents. - This string holds the actual html. Use it to retrieve the contents.
- The main document interface, including a html parser.
Member Quick Reference Member Name Description clear . contentType If you're using this for some other kind of XML, you can set the content type here. createElement . createForm . createFragment . createTextNode . findFirst . forms . getData implementing the FileResource interface; it calls toString. getElementById These functions all forward to the root element. See the documentation in the Element class. getElementsBySelector These functions all forward to the root element. See the documentation in the Element class. getElementsByTagName These functions all forward to the root element. See the documentation in the Element class. getFirstElementByTagName FIXME:
btw, this could just be a lazy range......getMeta this uses a weird thing... it's [name=] if no colon and [property=] if colon loose . mainBody This returns the element, if there is one. (It different than Javascript, where it is called 'body', because body is a keyword in D.) 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. parse Take XMLish data and try to make the DOM tree out of it. parseGarbage Concatenates any consecutive text nodes Given the kind of garbage you find on the Internet, try to make sense of it. Equivalent to document.parse(data, false, false, null); (Case-insensitive, non-strict, determine character encoding from the data.) prolog . querySelector These functions all forward to the root element. See the documentation in the Element class. querySelectorAll These functions all forward to the root element. See the documentation in the Element class. requireElementById These functions all forward to the root element. See the documentation in the Element class. requireSelector These functions all forward to the root element. See the documentation in the Element class. root . setMeta Sets a meta tag in the document header. It is kinda hacky to work easily for both Facebook open graph and traditional html meta tags/ setProlog . title Sets the title of the page, creating a element if needed. toString . - this(string data, bool caseSensitive = false, bool strict = false);
- .
- this();
- Creates an empty document. It has *nothing* in it at all.
- 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.
Example:
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. - If you're using this for some other kind of XML, you can
set the content type here.
Note:
this has no impact on the function of this class. It is only used if the document is sent via a protocol like HTTP. This may be called by parse() if it recognizes the data. Otherwise, if you don't set it, it assumes text/html; charset=utf-8. - implementing the FileResource interface, useful for sending via http automatically.
- implementing the FileResource interface; it calls toString.
- Concatenates any consecutive text nodes
Given the kind of garbage you find on the Internet, try to make sense of it.
Equivalent to document.parse(data, false, false, null);
(Case-insensitive, non-strict, determine character encoding from the data.)
NOTE:
this makes no attempt at added security. - 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 dataEncoding argument can be used to pass a specific charset encoding for automatic conversion. If null (which is NOT the default!), it tries to determine from the data itself, using the xml prolog or meta tags, and assumes UTF-8 if unsure. If this assumption is wrong, it can throw on non-ascii characters! Note that it previously assumed the data was encoded as UTF-8, which is why the dataEncoding argument defaults to that. So it shouldn't break backward compatibility. But, if you want the best behavior on wild data - figuring it out from the document instead of assuming - you'll probably want to change that argument to null.
- Gets the
element's innerText, if one exists - Sets the title of the page, creating a
element if needed. - Element getElementById(string id);
SomeElementType requireElementById(SomeElementType = Element)(string id);
SomeElementType requireSelector(SomeElementType = Element, string file = __FILE__, int line = __LINE__)(string selector);
Element querySelector(string selector);
Element[] querySelectorAll(string selector);
Element[] getElementsBySelector(string selector);
Element[] getElementsByTagName(string tag); - These functions all forward to the root element. See the documentation in the Element class.
- FIXME:
btw, this could just be a lazy range...... - This returns the element, if there is one. (It different than Javascript, where it is called 'body', because body is a keyword in D.)
- this uses a weird thing... it's [name=] if no colon and [property=] if colon
- Sets a meta tag in the document header. It is kinda hacky to work easily for both Facebook open graph and traditional html meta tags/
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- Specializes Document for handling generic XML. (always uses strict mode, uses xml mime type and file header)
- .
- .
- .
- .
- .
Member Quick Reference Member Name Description attributesEndsWith [attr$=value] attributesEqual [attr=value] attributesInclude [attr*=value] attributesIncludesSeparatedByDashes [attr|=value] attributesIncludesSeparatedBySpaces [attr~=value] attributesNotEqual [attr!=value] -- extension by me attributesPresent [attr] attributesStartsWith [attr^=value] emptyElement . evenChild . firstChild . lastChild . matchElement . oddChild . rootElement . separation -1 == only itself; the null selector, 0 == tree, 1 == childNodes, 2 == childAfter, 3 == youngerSibling, 4 == parentOf tagNameFilter . toString . - .
- [attr]
- [attr=value]
- [attr^=value]
- [attr$=value]
- [attr~=value]
- [attr|=value]
- [attr*=value]
- [attr!=value] -- extension by me
- .
- .
- .
- .
- .
- .
- -1 == only itself; the null selector, 0 == tree, 1 == childNodes, 2 == childAfter, 3 == youngerSibling, 4 == parentOf
- .
- .
- .
- .
Member Quick Reference Member Name Description fromString . getElements . matchElement If relativeTo == null, it assumes the root of the parent document. parts . toString . - .
- .
- .
- If relativeTo == null, it assumes the root of the parent document.
- .
- .
- .
- .
- Converts a camel cased propertyName to a css style dashed property-name
- Translates a css style property-name to a camel cased propertyName
- This is probably not useful to you unless you're writing a browser or something like that.
It represents a *computed* style, like what the browser gives you after applying stylesheets, inline styles, and html attributes.
From here, you can start to make a layout engine for the box model and have a css aware browser.
Member Quick Reference Member Name Description Property . Specificity . classes . expandShortForm . getSpecificityOfRule . getValue takes dash style name givenExplicitly this is false if for example the user said "padding" and this is "padding-left" ids . important 0 = none, 1 = stylesheet author, 2 = inline style, 3 = user important . name . opDispatch . originatingRule . originatingSpecificity . properties . score . setValue takes dash style name specificity . tags . toString . value . - This probably isn't useful, unless you're writing a browser or something like that.
You might want to look at arsd.html for css macro, nesting, etc., or just use standard css
as text.
The idea, however, is to represent a kind of CSS object model, complete with specificity,
that you can apply to your documents to build the complete computedStyle object.
Member Quick Reference Member Name Description apply Run through the document and apply this stylesheet to it. The computedStyle member will be accurate after this call rules . - This is kinda private; just a little utility container for use by the ElementStream class.
Member Quick Reference Member Name Description arr . empty . peek . pop . push . - .
- .
- .
- .
- .
- This is the lazy range that walks the tree for you. It tries to go in the lexical order of the source: node, then children from first to last, each recursively.
Member Quick Reference Member Name Description currentKilled You should call this when you remove an element from the tree. It then doesn't recurse into that node and adjusts the current position, keeping the range stable. empty . front . popFront . - .
- this(Element start);
- Use Element.tree instead.
- .
- You should call this when you remove an element from the tree. It then doesn't recurse into that node and adjusts the current position, keeping the range stable.
- .
- used for DOM events
- This is a DOM event, like in javascript. Note that this library never fires events - it is only here for you to use if you want it.
Member Quick Reference Member Name Description dispatch this dispatches the element using the capture -> target -> bubble process preventDefault Prevents the default event handler (if there is one) from being called send this sends it only to the target. If you want propagation, use dispatch() instead. stopPropagation Stops the event propagation immediately. - Prevents the default event handler (if there is one) from being called
- Stops the event propagation immediately.
- this sends it only to the target. If you want propagation, use dispatch() instead.
- this dispatches the element using the capture -> target -> bubble process