public class Element
extends com.google.gwt.dom.client.Element
| Modifier and Type | Field and Description |
|---|---|
static String |
INNER_HTML_PLACEHOLDER
The text used in an element's meta data as a place holder for that element's outer HTML.
|
static String |
META_DATA_ATTR
The name of the DOM attribute storing the HTML of the meta data.
|
static String |
META_DATA_REF
The name of the JavaScript property storing the reference to the meta data.
NOTE: We can't use the same name as for META_DATA_ATTR because IE stores attribute values as JavaScript
properties of DOM element objects. |
| Modifier | Constructor and Description |
|---|---|
protected |
Element()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static Element |
as(com.google.gwt.dom.client.Node node)
Casts a
Node to an instance of this type. |
boolean |
canHaveChildren() |
void |
ensureEditable()
Ensures this element can be edited in design mode.
|
Element |
expandInnerMetaData()
Expands inner elements with meta data.
|
com.google.gwt.dom.client.Node |
expandMetaData(boolean deep)
Expands the meta data of this element and its descendants.
|
DocumentFragment |
extractContents()
Places all the children of this element in a document fragment and returns it.
NOTE: The element will remain empty after this method call. |
com.google.gwt.core.client.JsArrayString |
getAttributeNames() |
Attribute |
getAttributeNode(String attributeName) |
String |
getComputedStyleProperty(String propertyName)
Returns the value of the specified CSS property for this element as it is computed by the browser before the
element is displayed.
|
DocumentFragment |
getMetaData() |
boolean |
hasAttributes() |
void |
removeProperty(String propertyName)
Removes a property from this element.
|
void |
setMetaData(DocumentFragment metaData)
Sets the meta data of this element.
|
void |
unwrap()
Replaces this element with its child nodes.
|
void |
wrap(com.google.gwt.dom.client.Node node)
Wraps the passed node and takes its place in its parent.
|
String |
xGetAttribute(String name)
Get the value for the specified attribute in cross browser manner.
|
String |
xGetInnerHTML() |
String |
xGetInnerText()
We need this method because
Element.getInnerText() includes commented text in the output. |
String |
xGetString() |
boolean |
xHasAttribute(String attributeName)
Checks if this element has the specified attribute.
|
void |
xRemoveAttribute(String attributeName)
Removes an attribute by name.
|
void |
xSetAttribute(String name,
String value)
Sets the value for the specified attribute in a cross browser manner.
|
void |
xSetInnerHTML(String html)
Set inner HTML in cross browser manner and notify the owner document.
|
addClassName, as, blur, dispatchEvent, focus, getAbsoluteBottom, getAbsoluteLeft, getAbsoluteRight, getAbsoluteTop, getAttribute, getClassName, getClientHeight, getClientWidth, getDir, getDraggable, getElementsByTagName, getFirstChildElement, getId, getInnerHTML, getInnerText, getLang, getNextSiblingElement, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getPreviousSiblingElement, getPropertyBoolean, getPropertyDouble, getPropertyInt, getPropertyJSO, getPropertyObject, getPropertyString, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getString, getStyle, getTabIndex, getTagName, getTitle, hasAttribute, hasClassName, hasTagName, is, is, removeAttribute, removeClassName, replaceClassName, scrollIntoView, setAttribute, setClassName, setDir, setDraggable, setId, setInnerHTML, setInnerSafeHtml, setInnerText, setLang, setPropertyBoolean, setPropertyDouble, setPropertyInt, setPropertyJSO, setPropertyObject, setPropertyString, setScrollLeft, setScrollTop, setTabIndex, setTitle, toggleClassNameappendChild, cloneNode, getChild, getChildCount, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, hasChildNodes, hasParentElement, insertAfter, insertBefore, insertFirst, isOrHasChild, removeAllChildren, removeChild, removeFromParent, replaceChild, setNodeValuepublic static final String INNER_HTML_PLACEHOLDER
public static final String META_DATA_REF
META_DATA_ATTR because IE stores attribute values as JavaScript
properties of DOM element objects.public static final String META_DATA_ATTR
protected Element()
public static Element as(com.google.gwt.dom.client.Node node)
Node to an instance of this type.node - the instance to be casted to this type.Element.public final com.google.gwt.core.client.JsArrayString getAttributeNames()
http://code.google.com/p/google-web-toolkit/issues/detail?id=3054public final String getComputedStyleProperty(String propertyName)
fontWeight) and it is used like this object.style.propertyJSName = value. The CSS
name has dash style (font-weight) and it is used like this propertyCSSName: value;.propertyName - the script name of the CSS property whose value is returned.public final void xSetInnerHTML(String html)
html - the html to set.DOMUtils#setInnerHTML(Element, String)},
http://code.google.com/p/google-web-toolkit/issues/detail?id=3146public final String xGetInnerHTML()
Element.getInnerHTML()public final String xGetString()
Element.getString()public final Element expandInnerMetaData()
public final com.google.gwt.dom.client.Node expandMetaData(boolean deep)
deep - true to expand the inner elements with meta data, false otherwisepublic final DocumentFragment extractContents()
public final void unwrap()
public final void wrap(com.google.gwt.dom.client.Node node)
node - the node to wrappublic final DocumentFragment getMetaData()
public final void setMetaData(DocumentFragment metaData)
metaData - a document fragment with additional information regarding this element.public final boolean canHaveChildren()
true if HTML Strict DTD specifies that this element can have children, false otherwisepublic final String xGetAttribute(String name)
name - the name of the attributeDOMUtils.getAttribute(Element, String)public final void xSetAttribute(String name, String value)
name - the name of the attributevalue - the value of the attributepublic final String xGetInnerText()
Element.getInnerText() includes commented text in the output.Element.getInnerText(),
http://code.google.com/p/google-web-toolkit/issues/detail?id=3275public final boolean hasAttributes()
true if this element has any attribute, false otherwisepublic final void ensureEditable()
public final void removeProperty(String propertyName)
NOTE: Dynamic properties (expandos) can't be removed from a DOM node in IE 6 and 7. Setting their value to
null or undefined makes them appear in the HTML serialization as attributes. Removing the
corresponding attribute fails in IE7 if the property value is shared between multiple elements, which can happen
if elements are cloned. The only solution we've found is to set the property to an empty JavaScript object in IE.
You should test if the value returned by Element.getPropertyObject(String) or Element.getPropertyJSO(String) is
not null and also if it matches your expected type.
propertyName - the name of the property to be removedElement.setPropertyBoolean(String, boolean),
Element.setPropertyDouble(String, double),
Element.setPropertyInt(String, int),
Element.setPropertyString(String, String)public final boolean xHasAttribute(String attributeName)
NOTE: We added this method in order to fix an IE7 bug in Element.removeAttribute(String). It seems that
Node.cloneNode(boolean) doesn't clone the attributes in IE7 but only copies their references to the clone. As
a consequence an attribute can be shared by multiple elements. When we Element.removeAttribute(String) the
specified flag is set to false and thus Element.hasAttribute(String), which uses this flag in
its IE7 implementation, mistakenly reports the attribute as missing from the rest of the elements that share it.
attributeName - the name of an attributetrue if this element has the specified attribute, false otherwiseElement.hasAttribute(String),
http://code.google.com/p/google-web-toolkit/issues/detail?id=4690public final Attribute getAttributeNode(String attributeName)
attributeName - the name of an attributepublic final void xRemoveAttribute(String attributeName)
We added this method to fix a bug in IE7 which allows shared attribute nodes. Removing a shared attribute affects all the element that share it and also can crash the browser if the attribute is remove twice.
attributeName - the name of the attribute to removexHasAttribute(String)Copyright © 2004–2015 XWiki. All rights reserved.