ModElement class
HTMLModElement) interface, which provides special properties (beyond the regular element object interface they also have available to them by inheritance) for manipulating modification elements.
@DocsEditable
@DomName('HTMLModElement')
class ModElement extends Element native "HTMLModElement" {
@DomName('HTMLModElement.cite')
@DocsEditable
String cite;
@DomName('HTMLModElement.dateTime')
@DocsEditable
String dateTime;
}
Extends
Interceptor > EventTarget > Node > Element > ModElement
Properties
final _NamedNodeMap $dom_attributes #
final _NamedNodeMap $dom_attributes
final int $dom_childElementCount #
final int $dom_childElementCount
final HtmlCollection $dom_children #
nsIDOMNodeList
of the current child elements.
final HtmlCollection $dom_children
String $dom_className #
String $dom_className
final Element $dom_firstElementChild #
null if the element has no child elements.
final Element $dom_firstElementChild
final Element $dom_lastElementChild #
null if the element has no child elements.
final Element $dom_lastElementChild
Map<String, String> attributes #
All attributes on this element.
Any modifications to the attribute map will automatically be applied to this element.
This only includes attributes which are not in a namespace
(such as 'xlink:href'), additional attributes can be accessed via
getNamespacedAttributes.
Map<String, String> get attributes => new _ElementAttributeMap(this);
void set attributes(Map<String, String> value) {
Map<String, String> attributes = this.attributes;
attributes.clear();
for (String key in value.keys) {
attributes[key] = value[key];
}
}
List<Element> children #
List of the direct children of this element.
This collection can be used to add and remove elements from the document.
var item = new DivElement();
item.text = 'Something';
document.body.children.add(item) // Item is now displayed on the page.
for (var element in document.body.children) {
element.style.background = 'red'; // Turns every child of body red.
}
List<Element> get children => new _ChildrenElementList._wrap(this);
void set children(List<Element> value) {
// Copy list first since we don't want liveness during iteration.
List copy = new List.from(value);
var children = this.children;
children.clear();
children.addAll(copy);
}
CssClassSet classes #
The set of CSS classes applied to this element.
This set makes it easy to add, remove or toggle the classes applied to this element.
element.classes.add('selected');
element.classes.toggle('isOnline');
element.classes.remove('selected');
CssClassSet get classes => new _ElementCssClassSet(this);
void set classes(Iterable<String> value) {
CssClassSet classSet = classes;
classSet.clear();
classSet.addAll(value);
}
final Rect client #
Gets the position of this element relative to the client area of the page.
Rect get client => new Rect(clientLeft, clientTop, clientWidth, clientHeight);
final int clientHeight #
final int clientHeight
final int clientLeft #
final int clientLeft
final int clientTop #
final int clientTop
final DocumentFragment content #
Gets the content of this template.
This is only supported if isTemplate is true.
@Experimental
DocumentFragment get content {
_ensureTemplate();
return _templateContent;
}
String contentEditable #
String contentEditable
Map<String, String> dataset #
Allows access to all custom data attributes (data-*) set on this element.
The keys for the map must follow these rules:
- The name must not begin with 'xml'.
- The name cannot contain a semi-colon (';').
- The name cannot contain any capital letters.
Any keys from markup will be converted to camel-cased keys in the map.
For example, HTML specified as:
<div data-my-random-value='value'></div>
Would be accessed in Dart as:
var value = element.dataset['myRandomValue'];
See also:
Map<String, String> get dataset => new _DataAttributeMap(attributes);
void set dataset(Map<String, String> value) {
final data = this.dataset;
data.clear();
for (String key in value.keys) {
data[key] = value[key];
}
}
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the
equality operator as well to maintain consistency.
int get hashCode => Primitives.objectHashCode(this);
String innerHtml #
String innerHtml
final bool isContentEditable #
final bool isContentEditable
final bool isTemplate #
Returns true if this node is a template.
A node is a template if tagName is TEMPLATE, or the node has the
'template' attribute and this tag supports attribute form for backwards
compatibility with existing HTML parsers. The nodes that can use attribute
form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP
and COL) and OPTION.
@Experimental bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate;
String lang #
String lang
var model #
The data model which is inherited through the tree.
This is only supported if isTemplate is true.
Setting this will destructive propagate the value to all descendant nodes, and reinstantiate all of the nodes expanded by this template.
Currently this does not support propagation through Shadow DOMs.
@Experimental get model => _model;
@Experimental
void set model(value) {
_ensureTemplate();
var syntax = TemplateElement.syntax[attributes['syntax']];
_model = value;
_Bindings._addBindings(this, model, syntax);
}
final Element nextElementSibling #
null if there's no sibling node.
final Element nextElementSibling
List<Node> nodes #
List<Node> get nodes {
return new _ChildNodeListLazy(this);
}
void set nodes(Iterable<Node> value) {
// Copy list first since we don't want liveness during iteration.
// TODO(jacobr): there is a better way to do this.
List copy = new List.from(value);
text = '';
for (Node node in copy) {
append(node);
}
}
final Rect offset #
Gets the offset of this element relative to its offsetParent.
Rect get offset => new Rect(offsetLeft, offsetTop, offsetWidth, offsetHeight);
final int offsetHeight #
final int offsetHeight
final int offsetLeft #
offsetParent's left border.
final int offsetLeft
final Element offsetParent #
final Element offsetParent
final int offsetTop #
offsetParent's top border.
final int offsetTop
final int offsetWidth #
final int offsetWidth
final Events on #
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
Events get on => new Events(this);
final Stream<Event> onAbort #
@DomName('Element.onabort')
@DocsEditable
Stream<Event> get onAbort => abortEvent.forTarget(this);
final Stream<Event> onBeforeCopy #
@DomName('Element.onbeforecopy')
@DocsEditable
Stream<Event> get onBeforeCopy => beforeCopyEvent.forTarget(this);
final Stream<Event> onBeforeCut #
@DomName('Element.onbeforecut')
@DocsEditable
Stream<Event> get onBeforeCut => beforeCutEvent.forTarget(this);
final Stream<Event> onBeforePaste #
@DomName('Element.onbeforepaste')
@DocsEditable
Stream<Event> get onBeforePaste => beforePasteEvent.forTarget(this);
final Stream<Event> onBlur #
@DomName('Element.onblur')
@DocsEditable
Stream<Event> get onBlur => blurEvent.forTarget(this);
final Stream<Event> onChange #
@DomName('Element.onchange')
@DocsEditable
Stream<Event> get onChange => changeEvent.forTarget(this);
final Stream<MouseEvent> onClick #
@DomName('Element.onclick')
@DocsEditable
Stream<MouseEvent> get onClick => clickEvent.forTarget(this);
final Stream<MouseEvent> onContextMenu #
@DomName('Element.oncontextmenu')
@DocsEditable
Stream<MouseEvent> get onContextMenu => contextMenuEvent.forTarget(this);
final Stream<Event> onCopy #
@DomName('Element.oncopy')
@DocsEditable
Stream<Event> get onCopy => copyEvent.forTarget(this);
final Stream<Event> onCut #
@DomName('Element.oncut')
@DocsEditable
Stream<Event> get onCut => cutEvent.forTarget(this);
final Stream<Event> onDoubleClick #
@DomName('Element.ondblclick')
@DocsEditable
Stream<Event> get onDoubleClick => doubleClickEvent.forTarget(this);
final Stream<MouseEvent> onDrag #
@DomName('Element.ondrag')
@DocsEditable
Stream<MouseEvent> get onDrag => dragEvent.forTarget(this);
final Stream<MouseEvent> onDragEnd #
@DomName('Element.ondragend')
@DocsEditable
Stream<MouseEvent> get onDragEnd => dragEndEvent.forTarget(this);
final Stream<MouseEvent> onDragEnter #
@DomName('Element.ondragenter')
@DocsEditable
Stream<MouseEvent> get onDragEnter => dragEnterEvent.forTarget(this);
final Stream<MouseEvent> onDragLeave #
@DomName('Element.ondragleave')
@DocsEditable
Stream<MouseEvent> get onDragLeave => dragLeaveEvent.forTarget(this);
final Stream<MouseEvent> onDragOver #
@DomName('Element.ondragover')
@DocsEditable
Stream<MouseEvent> get onDragOver => dragOverEvent.forTarget(this);
final Stream<MouseEvent> onDragStart #
@DomName('Element.ondragstart')
@DocsEditable
Stream<MouseEvent> get onDragStart => dragStartEvent.forTarget(this);
final Stream<MouseEvent> onDrop #
@DomName('Element.ondrop')
@DocsEditable
Stream<MouseEvent> get onDrop => dropEvent.forTarget(this);
final Stream<Event> onError #
@DomName('Element.onerror')
@DocsEditable
Stream<Event> get onError => errorEvent.forTarget(this);
final Stream<Event> onFocus #
@DomName('Element.onfocus')
@DocsEditable
Stream<Event> get onFocus => focusEvent.forTarget(this);
final Stream<Event> onFullscreenChange #
@DomName('Element.onwebkitfullscreenchange')
@DocsEditable
Stream<Event> get onFullscreenChange => fullscreenChangeEvent.forTarget(this);
final Stream<Event> onFullscreenError #
@DomName('Element.onwebkitfullscreenerror')
@DocsEditable
Stream<Event> get onFullscreenError => fullscreenErrorEvent.forTarget(this);
final Stream<Event> onInput #
@DomName('Element.oninput')
@DocsEditable
Stream<Event> get onInput => inputEvent.forTarget(this);
final Stream<Event> onInvalid #
@DomName('Element.oninvalid')
@DocsEditable
Stream<Event> get onInvalid => invalidEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyDown #
@DomName('Element.onkeydown')
@DocsEditable
Stream<KeyboardEvent> get onKeyDown => keyDownEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyPress #
@DomName('Element.onkeypress')
@DocsEditable
Stream<KeyboardEvent> get onKeyPress => keyPressEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyUp #
@DomName('Element.onkeyup')
@DocsEditable
Stream<KeyboardEvent> get onKeyUp => keyUpEvent.forTarget(this);
final Stream<Event> onLoad #
@DomName('Element.onload')
@DocsEditable
Stream<Event> get onLoad => loadEvent.forTarget(this);
final Stream<MouseEvent> onMouseDown #
@DomName('Element.onmousedown')
@DocsEditable
Stream<MouseEvent> get onMouseDown => mouseDownEvent.forTarget(this);
final Stream<MouseEvent> onMouseMove #
@DomName('Element.onmousemove')
@DocsEditable
Stream<MouseEvent> get onMouseMove => mouseMoveEvent.forTarget(this);
final Stream<MouseEvent> onMouseOut #
@DomName('Element.onmouseout')
@DocsEditable
Stream<MouseEvent> get onMouseOut => mouseOutEvent.forTarget(this);
final Stream<MouseEvent> onMouseOver #
@DomName('Element.onmouseover')
@DocsEditable
Stream<MouseEvent> get onMouseOver => mouseOverEvent.forTarget(this);
final Stream<MouseEvent> onMouseUp #
@DomName('Element.onmouseup')
@DocsEditable
Stream<MouseEvent> get onMouseUp => mouseUpEvent.forTarget(this);
final Stream<WheelEvent> onMouseWheel #
@DomName('Element.onmousewheel')
@DocsEditable
Stream<WheelEvent> get onMouseWheel => mouseWheelEvent.forTarget(this);
final Stream<Event> onPaste #
@DomName('Element.onpaste')
@DocsEditable
Stream<Event> get onPaste => pasteEvent.forTarget(this);
final Stream<Event> onReset #
@DomName('Element.onreset')
@DocsEditable
Stream<Event> get onReset => resetEvent.forTarget(this);
final Stream<Event> onScroll #
@DomName('Element.onscroll')
@DocsEditable
Stream<Event> get onScroll => scrollEvent.forTarget(this);
final Stream<Event> onSearch #
@DomName('Element.onsearch')
@DocsEditable
Stream<Event> get onSearch => searchEvent.forTarget(this);
final Stream<Event> onSelect #
@DomName('Element.onselect')
@DocsEditable
Stream<Event> get onSelect => selectEvent.forTarget(this);
final Stream<Event> onSelectStart #
@DomName('Element.onselectstart')
@DocsEditable
Stream<Event> get onSelectStart => selectStartEvent.forTarget(this);
final Stream<Event> onSubmit #
@DomName('Element.onsubmit')
@DocsEditable
Stream<Event> get onSubmit => submitEvent.forTarget(this);
final Stream<TouchEvent> onTouchCancel #
@DomName('Element.ontouchcancel')
@DocsEditable
Stream<TouchEvent> get onTouchCancel => touchCancelEvent.forTarget(this);
final Stream<TouchEvent> onTouchEnd #
@DomName('Element.ontouchend')
@DocsEditable
Stream<TouchEvent> get onTouchEnd => touchEndEvent.forTarget(this);
final Stream<TouchEvent> onTouchEnter #
@DomName('Element.ontouchenter')
@DocsEditable
Stream<TouchEvent> get onTouchEnter => touchEnterEvent.forTarget(this);
final Stream<TouchEvent> onTouchLeave #
@DomName('Element.ontouchleave')
@DocsEditable
Stream<TouchEvent> get onTouchLeave => touchLeaveEvent.forTarget(this);
final Stream<TouchEvent> onTouchMove #
@DomName('Element.ontouchmove')
@DocsEditable
Stream<TouchEvent> get onTouchMove => touchMoveEvent.forTarget(this);
final Stream<TouchEvent> onTouchStart #
@DomName('Element.ontouchstart')
@DocsEditable
Stream<TouchEvent> get onTouchStart => touchStartEvent.forTarget(this);
final Stream<TransitionEvent> onTransitionEnd #
@DomName('Element.onwebkitTransitionEnd')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE, '10')
@SupportedBrowser(SupportedBrowser.SAFARI)
Stream<TransitionEvent> get onTransitionEnd => transitionEndEvent.forTarget(this);
final String outerHtml #
final String outerHtml
final Element previousElementSibling #
null if there is no sibling element.
final Element previousElementSibling
final Element ref #
Gets the template this node refers to.
This is only supported if isTemplate is true.
@Experimental
Element get ref {
_ensureTemplate();
Element ref = null;
var refId = attributes['ref'];
if (refId != null) {
ref = document.getElementById(refId);
}
return ref != null ? ref : _templateInstanceRef;
}
final Type runtimeType #
A representation of the runtime type of the object.
Type get runtimeType => getRuntimeType(this);
final int scrollHeight #
final int scrollHeight
int scrollLeft #
int scrollLeft
final int scrollWidth #
final int scrollWidth
bool spellcheck #
bool spellcheck
final CssStyleDeclaration style #
final CssStyleDeclaration style
int tabIndex #
int tabIndex
final String tagName #
final String tagName
final TemplateInstance templateInstance #
Gets the template instance that instantiated this node, if any.
@Experimental TemplateInstance get templateInstance => _templateInstance != null ? _templateInstance : (parent != null ? parent.templateInstance : null);
String title #
String title
var xtag #
Experimental support for web components. This field stores a
reference to the component implementation. It was inspired by Mozilla's
x-tags project. Please note: in the future it may be possible to
extend Element from your class, in which case this field will be
deprecated.
If xtag has not been set, it will simply return this Element.
get xtag => _xtag != null ? _xtag : this;
void set xtag(Element value) {
_xtag = value;
}
Operators
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override
the hashCode method as well to maintain consistency.
bool operator ==(other) => identical(this, other);
Methods
Node append(Node newChild) #
Adds a node to the end of the child nodes list of this node.
If the node already exists in this document, it will be removed from its current parent node, then added to this node.
This method is more efficient than nodes.add, and is the preferred
way of appending a child node.
@JSName('appendChild')
/**
* Adds a node to the end of the child [nodes] list of this node.
*
* If the node already exists in this document, it will be removed from its
* current parent node, then added to this node.
*
* This method is more efficient than `nodes.add`, and is the preferred
* way of appending a child node.
*/
@DomName('Node.appendChild')
@DocsEditable
Node append(Node newChild) native;
void appendHtml(String text) #
Parses the specified text as HTML and adds the resulting node after the last child of this element.
void appendHtml(String text) {
this.insertAdjacentHtml('beforeend', text);
}
void appendText(String text) #
Adds the specified text as a text node after the last child of this element.
void appendText(String text) {
this.insertAdjacentText('beforeend', text);
}
void bind(String name, model, String path) #
Binds the attribute
name to the
path of the
model.
Path is a String of accessors such as foo.bar.baz.
@Experimental
void bind(String name, model, String path) {
_bindElement(this, name, model, path);
}
void blur() #
@DomName('Element.blur')
@DocsEditable
void blur() native;
void click() #
@DomName('Element.click')
@DocsEditable
void click() native;
Node clone(bool deep) #
@JSName('cloneNode')
@DomName('Node.cloneNode')
@DocsEditable
Node clone(bool deep) native;
bool contains(Node other) #
@DomName('Node.contains')
@DocsEditable
bool contains(Node other) native;
DocumentFragment createInstance() #
Creates an instance of the template.
This is only supported if isTemplate is true.
@Experimental
DocumentFragment createInstance() {
_ensureTemplate();
var template = ref;
if (template == null) template = this;
var instance = _Bindings._createDeepCloneAndDecorateTemplates(
template.content, attributes['syntax']);
if (TemplateElement._instanceCreated != null) {
TemplateElement._instanceCreated.add(instance);
}
return instance;
}
ShadowRoot createShadowRoot() #
@JSName('webkitCreateShadowRoot')
@DomName('Element.webkitCreateShadowRoot')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME, '25')
@Experimental
ShadowRoot createShadowRoot() native;
bool dispatchEvent(Event event) #
@DomName('Node.dispatchEvent')
@DocsEditable
bool dispatchEvent(Event event) native;
void focus() #
@DomName('Element.focus')
@DocsEditable
void focus() native;
Rect getBoundingClientRect() #
@DomName('Element.getBoundingClientRect')
@DocsEditable
Rect getBoundingClientRect() native;
List<Rect> getClientRects() #
@DomName('Element.getClientRects')
@DocsEditable
@Returns('_ClientRectList')
@Creates('_ClientRectList')
List<Rect> getClientRects() native;
CssStyleDeclaration getComputedStyle([String pseudoElement]) #
The set of all CSS values applied to this element, including inherited and default values.
The computedStyle contains values that are inherited from other
sources, such as parent elements or stylesheets. This differs from the
style property, which contains only the values specified directly on this
element.
PseudoElement can be values such as ::after, ::before, ::marker,
::line-marker.
See also:
CssStyleDeclaration getComputedStyle([String pseudoElement]) {
if (pseudoElement == null) {
pseudoElement = '';
}
// TODO(jacobr): last param should be null, see b/5045788
return window.$dom_getComputedStyle(this, pseudoElement);
}
List<Node> getElementsByClassName(String name) #
@DomName('Element.getElementsByClassName')
@DocsEditable
@Returns('NodeList')
@Creates('NodeList')
List<Node> getElementsByClassName(String name) native;
Map<String, String> getNamespacedAttributes(String namespace) #
Gets a map for manipulating the attributes of a particular namespace.
This is primarily useful for SVG attributes such as xref:link.
Map<String, String> getNamespacedAttributes(String namespace) {
return new _NamespacedAttributeMap(this, namespace);
}
List<Range> getRegionFlowRanges() #
@JSName('webkitGetRegionFlowRanges')
@DomName('Element.webkitGetRegionFlowRanges')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
List<Range> getRegionFlowRanges() native;
bool hasChildNodes() #
@DomName('Node.hasChildNodes')
@DocsEditable
bool hasChildNodes() native;
Element insertAdjacentElement(String where, Element element) #
Inserts element into the DOM at the specified location.
To see the possible values for
where, read the doc for
insertAdjacentHtml.
See also:
insertAdjacentHtml
Element insertAdjacentElement(String where, Element element) {
if (JS('bool', '!!#.insertAdjacentElement', this)) {
_insertAdjacentElement(where, element);
} else {
_insertAdjacentNode(where, element);
}
return element;
}
void insertAdjacentHtml(String where, String html) #
Parses text as an HTML fragment and inserts it into the DOM at the specified location.
The where parameter indicates where to insert the HTML fragment:
- 'beforeBegin': Immediately before this element.
- 'afterBegin': As the first child of this element.
- 'beforeEnd': As the last child of this element.
-
'afterEnd': Immediately after this element.
var html = '<div class="something">content</div>'; // Inserts as the first child document.body.insertAdjacentHtml('afterBegin', html); var createdElement = document.body.children
0; print(createdElement.classes0); // Prints 'something'
See also:
insertAdjacentTextinsertAdjacentElement
void insertAdjacentHtml(String where, String html) {
if (JS('bool', '!!#.insertAdjacentHtml', this)) {
_insertAdjacentHtml(where, html);
} else {
_insertAdjacentNode(where, new DocumentFragment.html(html));
}
}
void insertAdjacentText(String where, String text) #
Creates a text node and inserts it into the DOM at the specified location.
To see the possible values for
where, read the doc for
insertAdjacentHtml.
See also:
insertAdjacentHtml
void insertAdjacentText(String where, String text) {
if (JS('bool', '!!#.insertAdjacentText', this)) {
_insertAdjacentText(where, text);
} else {
_insertAdjacentNode(where, new Text(text));
}
}
Node insertAllBefore(Iterable<Node> newNodes, Node refChild) #
Inserts all of the nodes into this node directly before refChild.
See also:
insertBefore
Node insertAllBefore(Iterable<Node> newNodes, Node refChild) {
if (newNodes is _ChildNodeListLazy) {
if (identical(newNodes._this, this)) {
throw new ArgumentError(newNodes);
}
// Optimized route for copying between nodes.
for (var i = 0, len = newNodes.length; i < len; ++i) {
// Should use $dom_firstChild, Bug 8886.
this.insertBefore(newNodes[0], refChild);
}
} else {
for (var node in newNodes) {
this.insertBefore(node, refChild);
}
}
}
Node insertBefore(Node newChild, Node refChild) #
@DomName('Node.insertBefore')
@DocsEditable
Node insertBefore(Node newChild, Node refChild) native;
bool matches(String selectors) #
Checks if this element matches the CSS selectors.
@Experimental
bool matches(String selectors) {
if (JS('bool', '!!#.matches', this)) {
return JS('bool', '#.matches(#)', this, selectors);
} else if (JS('bool', '!!#.webkitMatchesSelector', this)) {
return JS('bool', '#.webkitMatchesSelector(#)', this, selectors);
} else if (JS('bool', '!!#.mozMatchesSelector', this)) {
return JS('bool', '#.mozMatchesSelector(#)', this, selectors);
} else if (JS('bool', '!!#.msMatchesSelector', this)) {
return JS('bool', '#.msMatchesSelector(#)', this, selectors);
}
throw new UnsupportedError("Not supported on this platform");
}
dynamic noSuchMethod(Invocation invocation) #
noSuchMethod is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to noSuchMethod in an Invocation.
If noSuchMethod returns a value, that value becomes the result of
the original invocation.
The default behavior of noSuchMethod is to throw a
noSuchMethodError.
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError(
this,
_symbolToString(invocation.memberName),
invocation.positionalArguments,
_symbolMapToStringMap(invocation.namedArguments));
}
void onCreated() #
Called by the DOM when this element has been instantiated.
@Experimental
void onCreated() {}
Element query(String selectors) #
Finds the first descendant element of this element that matches the specified group of selectors.
selectors should be a string using CSS selector syntax.
// Gets the first descendant with the class 'classname'
var element = element.query('.className');
// Gets the element with id 'id'
var element = element.query('#id');
// Gets the first descendant [ImageElement]
var img = element.query('img');
See also:
@JSName('querySelector')
/**
* Finds the first descendant element of this element that matches the
* specified group of selectors.
*
* [selectors] should be a string using CSS selector syntax.
*
* // Gets the first descendant with the class 'classname'
* var element = element.query('.className');
* // Gets the element with id 'id'
* var element = element.query('#id');
* // Gets the first descendant [ImageElement]
* var img = element.query('img');
*
* See also:
*
* * [CSS Selectors](http://docs.webplatform.org/wiki/css/selectors)
*/
@DomName('Element.querySelector')
@DocsEditable
Element query(String selectors) native;
ElementList queryAll(String selectors) #
Finds all descendent elements of this element that match the specified group of selectors.
selectors should be a string using CSS selector syntax.
var items = element.query('.itemClassName');
ElementList queryAll(String selectors) => new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
void remove() #
Removes this node from the DOM.
@DomName('Node.removeChild')
void remove() {
// TODO(jacobr): should we throw an exception if parent is already null?
// TODO(vsm): Use the native remove when available.
if (this.parentNode != null) {
final Node parent = this.parentNode;
parentNode.$dom_removeChild(this);
}
}
Node replaceWith(Node otherNode) #
Replaces this node with another node.
@DomName('Node.replaceChild')
Node replaceWith(Node otherNode) {
try {
final Node parent = this.parentNode;
parent.$dom_replaceChild(otherNode, this);
} catch (e) {
};
return this;
}
void requestFullscreen() #
@JSName('webkitRequestFullscreen')
@DomName('Element.webkitRequestFullscreen')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void requestFullscreen() native;
void requestFullScreen(int flags) #
@JSName('webkitRequestFullScreen')
@DomName('Element.webkitRequestFullScreen')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void requestFullScreen(int flags) native;
void requestPointerLock() #
@JSName('webkitRequestPointerLock')
@DomName('Element.webkitRequestPointerLock')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void requestPointerLock() native;
void scrollByLines(int lines) #
@DomName('Element.scrollByLines')
@DocsEditable
void scrollByLines(int lines) native;
void scrollByPages(int pages) #
@DomName('Element.scrollByPages')
@DocsEditable
void scrollByPages(int pages) native;
void scrollIntoView([ScrollAlignment alignment]) #
Scrolls this element into view.
Only one of of the alignment options may be specified at a time.
If no options are specified then this will attempt to scroll the minimum amount needed to bring the element into view.
Note that alignCenter is currently only supported on WebKit platforms. If alignCenter is specified but not supported then this will fall back to alignTop.
See also:
void scrollIntoView([ScrollAlignment alignment]) {
var hasScrollIntoViewIfNeeded = false;
hasScrollIntoViewIfNeeded =
JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
if (alignment == ScrollAlignment.TOP) {
this.$dom_scrollIntoView(true);
} else if (alignment == ScrollAlignment.BOTTOM) {
this.$dom_scrollIntoView(false);
} else if (hasScrollIntoViewIfNeeded) {
if (alignment == ScrollAlignment.CENTER) {
this.$dom_scrollIntoViewIfNeeded(true);
} else {
this.$dom_scrollIntoViewIfNeeded();
}
} else {
this.$dom_scrollIntoView();
}
}
String toString() #
Print out a String representation of this Node.
String toString() => localName == null ? (nodeValue == null ? super.toString() : nodeValue) : localName;
void unbind(String name) #
Unbinds the attribute name.
@Experimental
void unbind(String name) {
_unbindElement(this, name);
}
void unbindAll() #
Unbinds all bound attributes.
@Experimental
void unbindAll() {
_unbindAllElement(this);
}
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) #
@JSName('addEventListener')
@DomName('Node.addEventListener')
@DocsEditable
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) native;
String $dom_getAttribute(String name) #
@JSName('getAttribute')
@DomName('Element.getAttribute')
@DocsEditable
String $dom_getAttribute(String name) native;
String $dom_getAttributeNS(String namespaceURI, String localName) #
@JSName('getAttributeNS')
@DomName('Element.getAttributeNS')
@DocsEditable
String $dom_getAttributeNS(String namespaceURI, String localName) native;
List<Node> $dom_getElementsByTagName(String name) #
@JSName('getElementsByTagName')
@DomName('Element.getElementsByTagName')
@DocsEditable
@Returns('NodeList')
@Creates('NodeList')
List<Node> $dom_getElementsByTagName(String name) native;
bool $dom_hasAttribute(String name) #
@JSName('hasAttribute')
@DomName('Element.hasAttribute')
@DocsEditable
bool $dom_hasAttribute(String name) native;
bool $dom_hasAttributeNS(String namespaceURI, String localName) #
@JSName('hasAttributeNS')
@DomName('Element.hasAttributeNS')
@DocsEditable
bool $dom_hasAttributeNS(String namespaceURI, String localName) native;
List<Node> $dom_querySelectorAll(String selectors) #
@JSName('querySelectorAll')
@DomName('Element.querySelectorAll')
@DocsEditable
@Returns('NodeList')
@Creates('NodeList')
List<Node> $dom_querySelectorAll(String selectors) native;
void $dom_removeAttribute(String name) #
@JSName('removeAttribute')
@DomName('Element.removeAttribute')
@DocsEditable
void $dom_removeAttribute(String name) native;
void $dom_removeAttributeNS(String namespaceURI, String localName) #
@JSName('removeAttributeNS')
@DomName('Element.removeAttributeNS')
@DocsEditable
void $dom_removeAttributeNS(String namespaceURI, String localName) native;
Node $dom_removeChild(Node oldChild) #
@JSName('removeChild')
@DomName('Node.removeChild')
@DocsEditable
Node $dom_removeChild(Node oldChild) native;
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) #
@JSName('removeEventListener')
@DomName('Node.removeEventListener')
@DocsEditable
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native;
Node $dom_replaceChild(Node newChild, Node oldChild) #
@JSName('replaceChild')
@DomName('Node.replaceChild')
@DocsEditable
Node $dom_replaceChild(Node newChild, Node oldChild) native;
void $dom_scrollIntoView([bool alignWithTop]) #
@JSName('scrollIntoView')
@DomName('Element.scrollIntoView')
@DocsEditable
void $dom_scrollIntoView([bool alignWithTop]) native;
void $dom_scrollIntoViewIfNeeded([bool centerIfNeeded]) #
@JSName('scrollIntoViewIfNeeded')
@DomName('Element.scrollIntoViewIfNeeded')
@DocsEditable
void $dom_scrollIntoViewIfNeeded([bool centerIfNeeded]) native;
void $dom_setAttribute(String name, String value) #
@JSName('setAttribute')
@DomName('Element.setAttribute')
@DocsEditable
void $dom_setAttribute(String name, String value) native;
void $dom_setAttributeNS(String namespaceURI, String qualifiedName, String value) #
@JSName('setAttributeNS')
@DomName('Element.setAttributeNS')
@DocsEditable
void $dom_setAttributeNS(String namespaceURI, String qualifiedName, String value) native;
This page includes content from the
Mozilla Foundation that is graciously
licensed under a
Creative Commons: Attribution-Sharealike license.
Mozilla has no other association with Dart or dartlang.org. We
encourage you to improve the web by
contributing to
The Mozilla Developer Network.