public class Element extends EventNode
DomElement
.ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Constructor and Description |
---|
Element()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
blur()
Remove focus from this element.
|
protected NamedNodeMap |
createAttributesObject()
Creates the JS object for the property attributes.
|
protected void |
createEventHandler(String eventName,
String attrValue)
Create the event handler function from the attribute value.
|
Object |
get(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object.
|
Object |
getAttribute(String attributeName,
Integer flags)
Returns the value of the specified attribute.
|
Object |
getAttributeNode(String name)
Retrieves an attribute node by name.
|
String |
getAttributeNS(String namespaceURI,
String localName)
Gets the specified attribute.
|
Object |
getAttributes()
Returns the attributes of this XML element.
|
String |
getBaseURI()
Returns the Base URI as a string.
|
ClientRect |
getBoundingClientRect()
Retrieves an object that specifies the bounds of a collection of TextRectangle objects.
|
int |
getChildElementCount()
Returns the current number of child elements.
|
HTMLCollection |
getChildren()
Gets the children of the current node.
|
DOMTokenList |
getClassList()
Gets the token list of class attribute.
|
ComputedCSSStyleDeclaration |
getCurrentStyle()
Returns the current (calculated) style object for this element.
|
DomElement |
getDomNodeOrDie()
Returns the DOM node that corresponds to this JavaScript object or throw
an exception if one cannot be found.
|
HTMLCollection |
getElementsByTagName(String tagName)
Returns all the descendant elements with the specified tag name.
|
Object |
getElementsByTagNameNS(Object namespaceURI,
String localName)
Returns a list of elements with the given tag name belonging to the given namespace.
|
Element |
getFirstElementChild()
Returns the first element child.
|
Element |
getLastElementChild()
Returns the last element child.
|
Element |
getNextElementSibling()
Returns the next element sibling.
|
Element |
getParentElement()
Gets the first ancestor instance of
Element . |
Element |
getPreviousElementSibling()
Returns the previous element sibling.
|
CSSStyleDeclaration |
getRuntimeStyle()
Returns the runtime style object for this element.
|
CSSStyleDeclaration |
getStyle()
Returns the style object for this element.
|
String |
getTagName()
Returns the tag name of this element.
|
boolean |
hasAttribute(String name)
Returns true when an attribute with a given name is specified on this element or has a default value.
|
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Test for attribute.
|
Node |
querySelector(String selectors)
Returns the first element within the document that matches the specified group of selectors.
|
StaticNodeList |
querySelectorAll(String selectors)
Retrieves all element nodes from descendants of the starting element node that match any selector
within the supplied selector strings.
|
void |
removeAttribute(String name)
Removes the specified attribute.
|
void |
removeAttributeNS(String namespaceURI,
String localName)
Removes the specified attribute.
|
void |
setAttribute(String name,
String value)
Sets an attribute.
|
Attr |
setAttributeNode(Attr newAtt)
Sets the attribute node for the specified attribute.
|
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
Sets the specified attribute.
|
void |
setDefaults(ComputedCSSStyleDeclaration style)
Callback method which allows different HTML element types to perform custom
initialization of computed styles.
|
void |
setDomNode(DomNode domNode)
Sets the DOM node that corresponds to this JavaScript object.
|
fireEvent, getOnblur, getOnclick, getOncontextmenu, getOndblclick, getOnerror, getOnfocus, getOnfocusin, getOnfocusout, getOninput, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnpropertychange, getOnresize, setOnblur, setOnclick, setOncontextmenu, setOndblclick, setOnerror, setOnfocus, setOnfocusin, setOnfocusout, setOninput, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnpropertychange, setOnresize
appendChild, asJavaScriptException, cloneNode, compareDocumentPosition, contains, detachEvent, getChildNodes, getFirstChild, getJavaScriptNode, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, insertBeforeImpl, isSameNode, normalize, removeChild, replaceChild, setNodeValue, setTextContent
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventHandlerProp, getEventListenersContainer, hasEventHandlers, removeEventListener, setEventHandler, setEventHandlerProp
clone, equivalentValues, getBrowserVersion, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public void setDomNode(DomNode domNode)
setDomNode
in class SimpleScriptable
domNode
- the DOM nodeprotected void createEventHandler(String eventName, String attrValue)
eventName
- the event name (ex: "onclick")attrValue
- the attribute valuepublic String getTagName()
public Object getAttributes()
getAttributes
in class Node
public String getBaseURI()
protected NamedNodeMap createAttributesObject()
public Object getAttribute(String attributeName, Integer flags)
attributeName
- attribute nameflags
- IE-specific flags (see the MSDN documentation for more info)null
if the attribute is not definedpublic void setAttribute(String name, String value)
name
- Name of the attribute to setvalue
- Value to set the attribute topublic HTMLCollection getElementsByTagName(String tagName)
tagName
- the name to search forpublic Object getAttributeNode(String name)
name
- the name of the attribute to retrievenull
if there is no such attributepublic Object getElementsByTagNameNS(Object namespaceURI, String localName)
namespaceURI
- the namespace URI of elements to look forlocalName
- is either the local name of elements to look for or the special value "*",
which matches all elements.public boolean hasAttribute(String name)
name
- the name of the attribute to look forpublic DomElement getDomNodeOrDie()
getDomNodeOrDie
in class SimpleScriptable
public void removeAttribute(String name)
name
- the name of the attribute to removepublic ClientRect getBoundingClientRect()
public int getChildElementCount()
public Element getFirstElementChild()
public Element getLastElementChild()
public Element getNextElementSibling()
public Element getPreviousElementSibling()
public Element getParentElement()
Element
. It is mostly identical
to Node.getParent()
except that it skips non Element
nodes.getParentElement
in class Node
Node.getParent()
public void setDefaults(ComputedCSSStyleDeclaration style)
style
- the style to initializepublic HTMLCollection getChildren()
public DOMTokenList getClassList()
public String getAttributeNS(String namespaceURI, String localName)
namespaceURI
- the namespace URIlocalName
- the local name of the attribute to look fornull
if the attribute is not definedpublic boolean hasAttributeNS(String namespaceURI, String localName)
namespaceURI
- the namespace URIlocalName
- the local name of the attribute to look fortrue
if the node has this attributepublic void setAttributeNS(String namespaceURI, String qualifiedName, String value)
namespaceURI
- the namespace URIqualifiedName
- the qualified name of the attribute to look forvalue
- the new attribute valuepublic void removeAttributeNS(String namespaceURI, String localName)
namespaceURI
- the namespace URI of the attribute to removelocalName
- the local name of the attribute to removepublic CSSStyleDeclaration getStyle()
public CSSStyleDeclaration getRuntimeStyle()
public ComputedCSSStyleDeclaration getCurrentStyle()
public Attr setAttributeNode(Attr newAtt)
newAtt
- the attribute to setpublic void blur()
public Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
SimpleScriptable.getWithPreemption(String)
.
For fallback case just implement ScriptableWithFallbackGetter
.
get
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
get
in class SimpleScriptable
public StaticNodeList querySelectorAll(String selectors)
selectors
- the selectorsCopyright © 2002–2016 Gargoyle Software Inc.. All rights reserved.