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.

More...

Members

Aliases

EventHandler
alias EventHandler = void delegate(Element handlerAttachedTo, Event event)

used for DOM events

Classes

AspCode
class AspCode

.

BangInstruction
class BangInstruction

.

CssStyle
class 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.

Document
class Document

The main document interface, including a html parser.

DocumentFragment
class DocumentFragment

.

Element
class Element

This represents almost everything in the DOM.

ElementNotFoundException
class 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
class 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.

Event
class 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
class Form

.

HtmlComment
class HtmlComment

.

Link
class Link

There are subclasses of Element offering improved helper functions for the element in HTML. */ ///

MarkupException
class MarkupException

.

PhpCode
class PhpCode

.

QuestionInstruction
class QuestionInstruction

.

RawSource
class RawSource

.

ServerSideCode
class ServerSideCode
SpecialElement
class SpecialElement
Stack
class Stack(T)

This is kinda private; just a little utility container for use by the ElementStream class.

StyleSheet
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
class Table

.

TableCell
class TableCell

Represents anything that can be a table cell - <td> or <th> html.

TableRow
class TableRow

Represents a table row element - a <tr>

TextNode
class TextNode

.

XmlDocument
class XmlDocument

Specializes Document for handling generic XML. (always uses strict mode, uses xml mime type and file header)

Enums

NodeType
enum NodeType

.

Functions

camelCase
string camelCase(string a)

Translates a css style property-name to a camel cased propertyName

findComments
Element[] findComments(Document document, string txt)
Element[] findComments(Element element, string txt)

finds comments that match the given txt. Case insensitive, strips whitespace.

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

.

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

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
string htmlEntitiesEncode(string data, Appender!string output = appender!string())

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
sizediff_t idToken(string str, sizediff_t position)

.

intFromHex
int intFromHex(string hex)

.

lexSelector
string[] lexSelector(string selector)

.

parseEntity
dchar parseEntity(in dchar[] entity)

This helper function is used for decoding html entities. It has a hard-coded list of entities and characters.

parseSelector
Selector parseSelector(string[] tokens, bool caseSensitiveTags = true)

.

parseSelectorString
Selector[] parseSelectorString(string selector, bool caseSensitiveTags = true)

.

removeDuplicates
Element[] removeDuplicates(Element[] input)

.

require
T require(Element e)

You can use this to do an easy null check or a dynamic cast+null check on any element.

unCamelCase
string unCamelCase(string a)

Converts a camel cased propertyName to a css style dashed property-name

xmlEntitiesEncode
string xmlEntitiesEncode(string data)

An alias for htmlEntitiesEncode; it works for xml too

Interfaces

FileResource
interface 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.

Mixin templates

DomConvenienceFunctions
mixin template DomConvenienceFunctions()

Static variables

selectorTokens
string[] selectorTokens;

.

Structs

DataSet
struct DataSet

A proxy object to do the Element class' dataset property. See Element.dataset for more info.

ElementCollection
struct ElementCollection
ElementStyle
struct 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.

FormFieldOptions
struct FormFieldOptions
Html
struct Html

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

Selector
struct Selector

.

SelectorPart
struct SelectorPart

.

Detailed Description

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.

Meta