InputElement class
Input objects expose the HTMLInputElement (or
HTML 4 HTMLInputElement) interface, which provides special properties and methods (beyond the regular element object interface they also have available to them by inheritance) for manipulating the layout and presentation of input elements.
@DomName('HTMLInputElement')
class InputElement extends Element implements
HiddenInputElement,
SearchInputElement,
TextInputElement,
UrlInputElement,
TelephoneInputElement,
EmailInputElement,
PasswordInputElement,
DateInputElement,
MonthInputElement,
WeekInputElement,
TimeInputElement,
LocalDateTimeInputElement,
NumberInputElement,
RangeInputElement,
CheckboxInputElement,
RadioButtonInputElement,
FileUploadInputElement,
SubmitButtonInputElement,
ImageButtonInputElement,
ResetButtonInputElement,
ButtonInputElement
native "HTMLInputElement" {
factory InputElement({String type}) {
var e = document.$dom_createElement("input");
if (type != null) {
try {
// IE throws an exception for unknown types.
e.type = type;
} catch(_) {}
}
return e;
}
@Creates('Null') // Set from Dart code; does not instantiate a native type.
_ValueBinding _valueBinding;
@Creates('Null') // Set from Dart code; does not instantiate a native type.
_CheckedBinding _checkedBinding;
@Experimental
void bind(String name, model, String path) {
switch (name) {
case 'value':
unbind('value');
attributes.remove('value');
_valueBinding = new _ValueBinding(this, model, path);
break;
case 'checked':
unbind('checked');
attributes.remove('checked');
_checkedBinding = new _CheckedBinding(this, model, path);
break;
default:
// TODO(jmesserly): this should be "super" (http://dartbug.com/10166).
// Similar issue for unbind/unbindAll below.
Element._bindElement(this, name, model, path);
break;
}
}
@Experimental
void unbind(String name) {
switch (name) {
case 'value':
if (_valueBinding != null) {
_valueBinding.unbind();
_valueBinding = null;
}
break;
case 'checked':
if (_checkedBinding != null) {
_checkedBinding.unbind();
_checkedBinding = null;
}
break;
default:
Element._unbindElement(this, name);
break;
}
}
@Experimental
void unbindAll() {
unbind('value');
unbind('checked');
Element._unbindAllElement(this);
}
@DomName('HTMLInputElement.webkitSpeechChangeEvent')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
static const EventStreamProvider<Event> speechChangeEvent = const EventStreamProvider<Event>('webkitSpeechChange');
@DomName('HTMLInputElement.accept')
@DocsEditable
String accept;
@DomName('HTMLInputElement.alt')
@DocsEditable
String alt;
@DomName('HTMLInputElement.autocomplete')
@DocsEditable
String autocomplete;
@DomName('HTMLInputElement.autofocus')
@DocsEditable
bool autofocus;
@DomName('HTMLInputElement.checked')
@DocsEditable
bool checked;
@DomName('HTMLInputElement.defaultChecked')
@DocsEditable
bool defaultChecked;
@DomName('HTMLInputElement.defaultValue')
@DocsEditable
String defaultValue;
@DomName('HTMLInputElement.dirName')
@DocsEditable
String dirName;
@DomName('HTMLInputElement.disabled')
@DocsEditable
bool disabled;
@DomName('HTMLInputElement.files')
@DocsEditable
@Returns('FileList')
@Creates('FileList')
List<File> files;
@DomName('HTMLInputElement.form')
@DocsEditable
final FormElement form;
@DomName('HTMLInputElement.formAction')
@DocsEditable
String formAction;
@DomName('HTMLInputElement.formEnctype')
@DocsEditable
String formEnctype;
@DomName('HTMLInputElement.formMethod')
@DocsEditable
String formMethod;
@DomName('HTMLInputElement.formNoValidate')
@DocsEditable
bool formNoValidate;
@DomName('HTMLInputElement.formTarget')
@DocsEditable
String formTarget;
@DomName('HTMLInputElement.height')
@DocsEditable
int height;
@DomName('HTMLInputElement.incremental')
@DocsEditable
bool incremental;
@DomName('HTMLInputElement.indeterminate')
@DocsEditable
bool indeterminate;
@DomName('HTMLInputElement.labels')
@DocsEditable
@Returns('NodeList')
@Creates('NodeList')
final List<Node> labels;
@DomName('HTMLInputElement.list')
@DocsEditable
final Element list;
@DomName('HTMLInputElement.max')
@DocsEditable
String max;
@DomName('HTMLInputElement.maxLength')
@DocsEditable
int maxLength;
@DomName('HTMLInputElement.min')
@DocsEditable
String min;
@DomName('HTMLInputElement.multiple')
@DocsEditable
bool multiple;
@DomName('HTMLInputElement.name')
@DocsEditable
String name;
@DomName('HTMLInputElement.pattern')
@DocsEditable
String pattern;
@DomName('HTMLInputElement.placeholder')
@DocsEditable
String placeholder;
@DomName('HTMLInputElement.readOnly')
@DocsEditable
bool readOnly;
@DomName('HTMLInputElement.required')
@DocsEditable
bool required;
@DomName('HTMLInputElement.selectionDirection')
@DocsEditable
String selectionDirection;
@DomName('HTMLInputElement.selectionEnd')
@DocsEditable
int selectionEnd;
@DomName('HTMLInputElement.selectionStart')
@DocsEditable
int selectionStart;
@DomName('HTMLInputElement.size')
@DocsEditable
int size;
@DomName('HTMLInputElement.src')
@DocsEditable
String src;
@DomName('HTMLInputElement.step')
@DocsEditable
String step;
@DomName('HTMLInputElement.type')
@DocsEditable
String type;
@DomName('HTMLInputElement.useMap')
@DocsEditable
String useMap;
@DomName('HTMLInputElement.validationMessage')
@DocsEditable
final String validationMessage;
@DomName('HTMLInputElement.validity')
@DocsEditable
final ValidityState validity;
@DomName('HTMLInputElement.value')
@DocsEditable
String value;
DateTime get valueAsDate => _convertNativeToDart_DateTime(this._get_valueAsDate);
@JSName('valueAsDate')
@DomName('HTMLInputElement.valueAsDate')
@DocsEditable
final dynamic _get_valueAsDate;
void set valueAsDate(DateTime value) {
this._set_valueAsDate = _convertDartToNative_DateTime(value);
}
void set _set_valueAsDate(/*dynamic*/ value) {
JS("void", "#.valueAsDate = #", this, value);
}
@DomName('HTMLInputElement.valueAsNumber')
@DocsEditable
num valueAsNumber;
@JSName('webkitEntries')
@DomName('HTMLInputElement.webkitEntries')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
@Returns('_EntryArray')
@Creates('_EntryArray')
final List<Entry> entries;
@JSName('webkitGrammar')
@DomName('HTMLInputElement.webkitGrammar')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
bool grammar;
@JSName('webkitSpeech')
@DomName('HTMLInputElement.webkitSpeech')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
bool speech;
@JSName('webkitdirectory')
@DomName('HTMLInputElement.webkitdirectory')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
bool directory;
@DomName('HTMLInputElement.width')
@DocsEditable
int width;
@DomName('HTMLInputElement.willValidate')
@DocsEditable
final bool willValidate;
@DomName('HTMLInputElement.checkValidity')
@DocsEditable
bool checkValidity() native;
@DomName('HTMLInputElement.select')
@DocsEditable
void select() native;
@DomName('HTMLInputElement.setCustomValidity')
@DocsEditable
void setCustomValidity(String error) native;
@DomName('HTMLInputElement.setRangeText')
@DocsEditable
void setRangeText(String replacement, {int start, int end, String selectionMode}) native;
@DomName('HTMLInputElement.setSelectionRange')
@DocsEditable
void setSelectionRange(int start, int end, [String direction]) native;
@DomName('HTMLInputElement.stepDown')
@DocsEditable
void stepDown([int n]) native;
@DomName('HTMLInputElement.stepUp')
@DocsEditable
void stepUp([int n]) native;
@DomName('HTMLInputElement.onwebkitSpeechChange')
@DocsEditable
Stream<Event> get onSpeechChange => speechChangeEvent.forTarget(this);
}
Extends
Interceptor > EventTarget > Node > Element > InputElement
Implements
ButtonInputElement, ResetButtonInputElement, ImageButtonInputElement, SubmitButtonInputElement, FileUploadInputElement, RadioButtonInputElement, CheckboxInputElement, RangeInputElement, NumberInputElement, LocalDateTimeInputElement, TimeInputElement, WeekInputElement, MonthInputElement, DateInputElement, PasswordInputElement, EmailInputElement, TelephoneInputElement, UrlInputElement, TextInputElement, SearchInputElement, HiddenInputElement
Static Properties
const EventStreamProvider<Event> speechChangeEvent #
static const EventStreamProvider<Event> speechChangeEvent = const EventStreamProvider<Event>('webkitSpeechChange')
Constructors
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];
}
}
String autocomplete #
- off: The user must explicitly enter a value into this field for every use, or the document provides its own auto-completion method; the browser does not automatically complete the entry.
- on: The browser can automatically complete the value based on values that the user has entered during previous uses.
String autocomplete
bool autofocus #
autofocus
HTML attribute, which specifies that a form control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form element in a document can have the autofocus attribute. It cannot be applied if the type attribute is set to hidden (that is, you cannot automatically set focus to a hidden control).
bool autofocus
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];
}
}
bool defaultChecked #
bool defaultChecked
String defaultValue #
String defaultValue
final FormElement form #
The containing form element, if this element is in a form. If this element is not contained in a form element:
final FormElement form
String formAction #
formaction
HTML attribute, containing the URI of a program that processes information submitted by the element. If specified, this attribute overrides the
action
attribute of the <form>
element that owns this element.
String formAction
String formMethod #
formmethod
HTML attribute, containing the HTTP method that the browser uses to submit the form. If specified, this attribute overrides the
method
attribute of the <form>
element that owns this element.
String formMethod
bool formNoValidate #
formnovalidate
HTML attribute, indicating that the form is not to be validated when it is submitted. If specified, this attribute overrides the
novalidate
attribute of the <form>
element that owns this element.
bool formNoValidate
String formTarget #
formtarget
HTML attribute, containing a name or keyword indicating where to display the response that is received after submitting the form. If specified, this attribute overrides the
target
attribute of the <form>
element that owns this element.
String formTarget
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
final Element list #
<datalist> element in the same document. The browser displays only options that are valid values for this input element. This attribute is ignored when the type attribute's value is hidden, checkbox, radio, file, or a button type.
final Element list
int maxLength #
Reflects the
maxlength
HTML attribute, containing the maximum length of text (in Unicode code points) that the value can be changed to. The constraint is evaluated only when the value is changed
maxlength to a negative value programmatically, an exception will be thrown.int maxLength
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> onSpeechChange #
@DomName('HTMLInputElement.onwebkitSpeechChange')
@DocsEditable
Stream<Event> get onSpeechChange => speechChangeEvent.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
String pattern #
pattern
HTML attribute, containing a regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url or email; otherwise it is ignored.
String pattern
String placeholder #
placeholder
HTML attribute, containing a hint to the user of what can be entered in the control. The placeholder text must not contain carriage returns or line-feeds. This attribute applies when the value of the type attribute is text, search, tel, url or email; otherwise it is ignored.
String placeholder
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
String selectionDirection #
String selectionDirection
int size #
size
HTML attribute, containing size of the control. This value is in pixels unless the value of type is text or password, in which case, it is an integer number of characters.
HTML5 Applies only when type is set to text, search, tel, url, email, or password; otherwise it is ignored.
int size
bool spellcheck #
bool spellcheck
String step #
step
HTML attribute, which works with min and max to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
String step
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
final String validationMessage #
final String validationMessage
final ValidityState validity #
final ValidityState validity
DateTime valueAsDate #
DateTime get valueAsDate => _convertNativeToDart_DateTime(this._get_valueAsDate);
void set valueAsDate(DateTime value) {
this._set_valueAsDate = _convertDartToNative_DateTime(value);
}
num valueAsNumber #
The value of the element, interpreted as one of the following in order:
- a time value
- a number
nullif conversion is not possible
num valueAsNumber
final bool willValidate #
final bool willValidate
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) {
switch (name) {
case 'value':
unbind('value');
attributes.remove('value');
_valueBinding = new _ValueBinding(this, model, path);
break;
case 'checked':
unbind('checked');
attributes.remove('checked');
_checkedBinding = new _CheckedBinding(this, model, path);
break;
default:
// TODO(jmesserly): this should be "super" (http://dartbug.com/10166).
// Similar issue for unbind/unbindAll below.
Element._bindElement(this, name, model, path);
break;
}
}
void blur() #
@DomName('Element.blur')
@DocsEditable
void blur() native;
bool checkValidity() #
invalid event at the element. It returns true if the element is not a candidate for constraint validation, or if it satisfies its constraints.
@DomName('HTMLInputElement.checkValidity')
@DocsEditable
bool checkValidity() 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 text) #
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 text) {
if (JS('bool', '!!#.insertAdjacentHtml', this)) {
_insertAdjacentHtml(where, text);
} else {
_insertAdjacentNode(where, new DocumentFragment.html(text));
}
}
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();
}
}
void select() #
@DomName('HTMLInputElement.select')
@DocsEditable
void select() native;
void setCustomValidity(String error) #
@DomName('HTMLInputElement.setCustomValidity')
@DocsEditable
void setCustomValidity(String error) native;
void setRangeText(String replacement, {int start, int end, String selectionMode}) #
@DomName('HTMLInputElement.setRangeText')
@DocsEditable
void setRangeText(String replacement, {int start, int end, String selectionMode}) native;
void setSelectionRange(int start, int end, [String direction]) #
selectionDirection parameter may be "forward" or "backward" to establish the direction in which selection was set, or "none"if the direction is unknown or not relevant. The default is "none". Specifying selectionDirection sets the value of the selectionDirection property.
@DomName('HTMLInputElement.setSelectionRange')
@DocsEditable
void setSelectionRange(int start, int end, [String direction]) native;
void stepDown([int n]) #
Decrements the value by (step * n), where n defaults to 1 if not specified. Throws an INVALID_STATE_ERR exception:
- if the method is not applicable to for the current type value.
- if the element has no step value.
- if the value cannot be converted to a number.
- if the resulting value is above the max or below the min.
@DomName('HTMLInputElement.stepDown')
@DocsEditable
void stepDown([int n]) native;
void stepUp([int n]) #
Increments the value by (step * n), where n defaults to 1 if not specified. Throws an INVALID_STATE_ERR exception:
- if the method is not applicable to for the current type value.
- if the element has no step value.
- if the value cannot be converted to a number.
- if the resulting value is above the max or below the min.
@DomName('HTMLInputElement.stepUp')
@DocsEditable
void stepUp([int n]) native;
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) {
switch (name) {
case 'value':
if (_valueBinding != null) {
_valueBinding.unbind();
_valueBinding = null;
}
break;
case 'checked':
if (_checkedBinding != null) {
_checkedBinding.unbind();
_checkedBinding = null;
}
break;
default:
Element._unbindElement(this, name);
break;
}
}
void unbindAll() #
Unbinds all bound attributes.
@Experimental
void unbindAll() {
unbind('value');
unbind('checked');
Element._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.