# Class DOMElement

  DOMNode
  DOMElement
  WPGMZA\DOMElement

Namespace: WPGMZA
Located at class.dom-element.php

Methods summary
`public` | # `__construct( )` #### Overrides `DOMElement::__construct()`
`public mixed` | # `querySelector( string $query )` Runs a CSS selector on the element. This is equivilant to Javascripts querySelector Runs a CSS selector on the element. This is equivilant to Javascripts querySelector #### Parameters $query a CSS selector #### Returns mixed The first descendant element that matches the selector, or NULL if there is no match
`public mixed` | # `querySelectorAll( $query, $sort = true )` Runs a CSS selector on the element. This is equivilant to Javascripts querySelectorAll Runs a CSS selector on the element. This is equivilant to Javascripts querySelectorAll #### Returns mixed Any descendant element's that match the selector, or NULL if there is no match
`public` | # `prepend( $subject )` Prepends the subject to this element. Prepends the subject to this element. #### Parameters $subject or array of elements #### Returns $this element
`public` | # `append( $subject )` Appends the subject to this element. Appends the subject to this element.
`public` | # `closest( mixed $selector )` Traverses from this node up it's ancestors and returns the first node that matches the given selector Traverses from this node up it's ancestors and returns the first node that matches the given selector #### Parameters $selector Either this node the first ancestor that matches this selector, or NULL if no match is found
`public boolean` | # `isBefore( $other )` Test if this element comes before the other element in the DOM tree Test if this element comes before the other element in the DOM tree #### Returns boolean TRUE if this element comes before the other, FALSE if not
`public integer` | # `getBreadth( )` Returns the breadth (sometimes called child index) of this node in regards to it's siblings Returns the breadth (sometimes called child index) of this node in regards to it's siblings #### Returns integer The index of this node
`public integer` | # `getDepth( )` Returns the depth of this node in regards to it's ancestors Returns the depth of this node in regards to it's ancestors #### Returns integer The depth of this node
`public static string` | # `selectorToXPath( string $selector )` #### Parameters $selector The CSS selector #### Returns string The resulting XPath expression
`public` | # `import( mixed $subject, $forcePHP = false )` Imports the supplied subject into this node. Imports the supplied subject into this node. #### Parameters $subject $subject. Either a \DOMDocument, \DOMNode, .html filename, or string containing HTML/text. The function will attempt to detect which. If you import HTML that contains a element, it will only import the inner body $forcePHP #### Returns $this element #### Throws Exception the subject was not recognised as any of the types above
`public` | # `setInlineStyle( string $name, string $value )` Sets an inline CSS style on this element. If it's already set, the old value will be removed first Sets an inline CSS style on this element. If it's already set, the old value will be removed first #### Parameters $name the CSS property name eg 'background-color' $value the value of the property eg '#ff4400' #### Returns $this
`public` | # `removeInlineStyle( string $name )` Removes the inline CSS style specified by name Removes the inline CSS style specified by name #### Parameters $name the name of the CSS property eg 'background-color' #### Returns $this
`public` | # `hasInlineStyle( string $name )` Check if this element has an inline style by name Check if this element has an inline style by name #### Parameters $name the name of the CSS property to test for
`public mixed` | # `getInlineStyle( string $name )` Gets the value of the inline style by name Gets the value of the inline style by name #### Parameters $name the name of the CSS property you want the value for #### Returns mixed FALSE if there is no style property or no style with that name exists, or a string containing the property value if it does
`public` | # `addClass( string $name )` Adds a class to this elements class attribute. It will be ignored if the class already exists Adds a class to this elements class attribute. It will be ignored if the class already exists #### Parameters $name The classname #### Returns $this
`public` | # `removeClass( string $name )` Removes the specified class from this nodes class attribute Removes the specified class from this nodes class attribute #### Parameters $name The classname #### Returns $this
`public boolean` | # `hasClass( string $name )` Tests if the specified class exists on this elements class attribute Tests if the specified class exists on this elements class attribute #### Parameters $name The classname #### Returns boolean FALSE if no such class existst, TRUE if it does
`protected` | # `populateElement( The $target, string $key, string $value, array $formatters )` Populates the target element. If it is a form element, the value will be set according to the elements type/nodeName. If not, the value will be imported instead. Populates the target element. If it is a form element, the value will be set according to the elements type/nodeName. If not, the value will be imported instead. #### Parameters $target element. Usually a descendant of this element $key the key of the value we're populating with, used for formatting $value the value to populate with $formatters an array associative of functions to format certain values with, functions should be specified by key
`public `WPGMZA\DOMElement`` | # `populate( mixed $src = null, array $formatters = null )` Takes a source object or associative array and optional array of formatting functions, and populates descendant named elements with the values from that source. Takes a source object or associative array and optional array of formatting functions, and populates descendant named elements with the values from that source. #### Parameters $src Associative array or object with the keys and values $formatters Optional associative array of functions to format values with. The keys on this array correspond with the keys on $src #### Returns `WPGMZA\DOMElement` This element
`public` | # `serializeFormData( )`
`public mixed` | # `getValue( )` Gets the value of this element Gets the value of this element #### Returns mixed A string if the element a text input, textarea or plain node, a boolean if the element is a checkbox or radio, or the value of the selected option if this element is a select
`public This` | # `setValue( $value )` Sets the value of this element. Intended for form elements only. If this element is a textarea, it will be appended as plain text. If this element is a select, it will attempt to select the option with the specified value. If the input is a radio or checkbox, it will set it accordingly. Otherwise, the value will be put into the value attribute Sets the value of this element. Intended for form elements only. If this element is a textarea, it will be appended as plain text. If this element is a select, it will attempt to select the option with the specified value. If the input is a radio or checkbox, it will set it accordingly. Otherwise, the value will be put into the value attribute #### Returns This element #### Throws Exception If this element is a select, SMART_STRICT_MODE is declared and no option with that value exists Exception If you call this method on a non-form element
`public Smart\Element` | # `appendText( $text )` Appends the specified text to this element, shorthand utility function Appends the specified text to this element, shorthand utility function #### Returns Smart\Element This element
`public` | # `insertAfter( Smart\Element $elem, Smart\Element $after = null )` Utility function to append the specified element after one of this elements children. Will append at the end if after is null Utility function to append the specified element after one of this elements children. Will append at the end if after is null #### Parameters $elem element to insert $after of this elements children, or null *@return \Smart\Element this element
`public Smart\Element` | # `clear( )` Clears this element, completely removing all it's contents Clears this element, completely removing all it's contents #### Returns Smart\Element This element
`public Smart\Element` | # `remove( )` Removes this element from it's parent Removes this element from it's parent #### Returns Smart\Element This element

Methods inherited from DOMElement
`getAttribute(), getAttributeNS(), getAttributeNode(), getAttributeNodeNS(), getElementsByTagName(), getElementsByTagNameNS(), hasAttribute(), hasAttributeNS(), removeAttribute(), removeAttributeNS(), removeAttributeNode(), setAttribute(), setAttributeNS(), setAttributeNode(), setAttributeNodeNS(), setIdAttribute(), setIdAttributeNS(), setIdAttributeNode()`

Methods inherited from DOMNode
`C14N(), C14NFile(), appendChild(), cloneNode(), compareDocumentPosition(), getFeature(), getLineNo(), getNodePath(), getUserData(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode(), isSameNode(), isSupported(), lookupNamespaceUri(), lookupPrefix(), normalize(), removeChild(), replaceChild(), setUserData()`

Properties summary
`protected static` | $xpathConverter | # ``