Dart API Reference
dart:html
Element
Element
class
An abstract class, which all HTML elements extend.
An abstract class, which all HTML elements extend.
Annotated by:
DocsEditable()
DomName('Element')
Extends:
Node
EventTarget
Object
Implements:
GlobalEventHandlers
ParentNode
ChildNode
Implementors
HtmlElement
InputElementBase
SvgElement
Constructors
Element.html
(
String
html
, {
NodeValidator
validator
,
NodeTreeSanitizer
treeSanitizer
} )
Creates an HTML element from a valid fragment of HTML.
Element.created
( )
Custom element creation constructor.
Element.tag
(
String
tag
, [
String
typeExtention
] )
Creates the HTML element specified by the tag name.
Element.a
( )
Creates a new <a> element.
Element.article
( )
Creates a new <article> element.
Element.aside
( )
Creates a new <aside> element.
Element.audio
( )
Creates a new <audio> element.
Element.br
( )
Creates a new <br> element.
Element.canvas
( )
Creates a new <canvas> element.
Element.div
( )
Creates a new <div> element.
Element.footer
( )
Creates a new <footer> element.
Element.header
( )
Creates a new <header> element.
Element.hr
( )
Creates a new <hr> element.
Element.iframe
( )
Creates a new <iframe> element.
Element.img
( )
Creates a new <img> element.
Element.li
( )
Creates a new <li> element.
Element.nav
( )
Creates a new <nav> element.
Element.ol
( )
Creates a new <ol> element.
Element.option
( )
Creates a new <option> element.
Element.p
( )
Creates a new <p> element.
Element.pre
( )
Creates a new <pre> element.
Element.section
( )
Creates a new <section> element.
Element.select
( )
Creates a new <select> element.
Element.span
( )
Creates a new <span> element.
Element.svg
( )
Creates a new <svg> element.
Element.table
( )
Creates a new <table> element.
Element.td
( )
Creates a new <td> element.
Element.textarea
( )
Creates a new <textarea> element.
Element.th
( )
Creates a new <th> element.
Element.tr
( )
Creates a new <tr> element.
Element.ul
( )
Creates a new <ul> element.
Element.video
( )
Creates a new <video> element.
Constants
abortEvent
=
const
EventStreamProvider
<
Event
>
('abort')
Static factory designed to expose abort events to event handlers that are not necessarily instances of
Element
.
beforeCopyEvent
=
const
EventStreamProvider
<
Event
>
('beforecopy')
Static factory designed to expose beforecopy events to event handlers that are not necessarily instances of
Element
.
beforeCutEvent
=
const
EventStreamProvider
<
Event
>
('beforecut')
Static factory designed to expose beforecut events to event handlers that are not necessarily instances of
Element
.
beforePasteEvent
=
const
EventStreamProvider
<
Event
>
('beforepaste')
Static factory designed to expose beforepaste events to event handlers that are not necessarily instances of
Element
.
blurEvent
=
const
EventStreamProvider
<
Event
>
('blur')
Static factory designed to expose blur events to event handlers that are not necessarily instances of
Element
.
canPlayEvent
=
const
EventStreamProvider
<
Event
>
('canplay')
canPlayThroughEvent
=
const
EventStreamProvider
<
Event
>
('canplaythrough')
changeEvent
=
const
EventStreamProvider
<
Event
>
('change')
Static factory designed to expose change events to event handlers that are not necessarily instances of
Element
.
clickEvent
=
const
EventStreamProvider
<
MouseEvent
>
('click')
Static factory designed to expose click events to event handlers that are not necessarily instances of
Element
.
contextMenuEvent
=
const
EventStreamProvider
<
MouseEvent
>
('contextmenu')
Static factory designed to expose contextmenu events to event handlers that are not necessarily instances of
Element
.
copyEvent
=
const
EventStreamProvider
<
Event
>
('copy')
Static factory designed to expose copy events to event handlers that are not necessarily instances of
Element
.
cutEvent
=
const
EventStreamProvider
<
Event
>
('cut')
Static factory designed to expose cut events to event handlers that are not necessarily instances of
Element
.
doubleClickEvent
=
const
EventStreamProvider
<
Event
>
('dblclick')
Static factory designed to expose doubleclick events to event handlers that are not necessarily instances of
Element
.
dragEvent
=
const
EventStreamProvider
<
MouseEvent
>
('drag')
A stream of drag events fired when an element is currently being dragged.
dragEndEvent
=
const
EventStreamProvider
<
MouseEvent
>
('dragend')
A stream of dragend events fired when an element completes a drag operation.
dragEnterEvent
=
const
EventStreamProvider
<
MouseEvent
>
('dragenter')
A stream of dragenter events fired when a dragged object is first dragged over an element.
dragLeaveEvent
=
const
EventStreamProvider
<
MouseEvent
>
('dragleave')
A stream of dragleave events fired when an object being dragged over an element leaves the element's target area.
dragOverEvent
=
const
EventStreamProvider
<
MouseEvent
>
('dragover')
A stream of dragover events fired when a dragged object is currently being dragged over an element.
dragStartEvent
=
const
EventStreamProvider
<
MouseEvent
>
('dragstart')
A stream of dragstart events for a dragged element whose drag has begun.
dropEvent
=
const
EventStreamProvider
<
MouseEvent
>
('drop')
A stream of drop events fired when a dragged object is dropped on an element.
durationChangeEvent
=
const
EventStreamProvider
<
Event
>
('durationchange')
emptiedEvent
=
const
EventStreamProvider
<
Event
>
('emptied')
endedEvent
=
const
EventStreamProvider
<
Event
>
('ended')
errorEvent
=
const
EventStreamProvider
<
Event
>
('error')
Static factory designed to expose error events to event handlers that are not necessarily instances of
Element
.
focusEvent
=
const
EventStreamProvider
<
Event
>
('focus')
Static factory designed to expose focus events to event handlers that are not necessarily instances of
Element
.
inputEvent
=
const
EventStreamProvider
<
Event
>
('input')
Static factory designed to expose input events to event handlers that are not necessarily instances of
Element
.
invalidEvent
=
const
EventStreamProvider
<
Event
>
('invalid')
Static factory designed to expose invalid events to event handlers that are not necessarily instances of
Element
.
keyDownEvent
=
const
EventStreamProvider
<
KeyboardEvent
>
('keydown')
Static factory designed to expose keydown events to event handlers that are not necessarily instances of
Element
.
keyPressEvent
=
const
EventStreamProvider
<
KeyboardEvent
>
('keypress')
Static factory designed to expose keypress events to event handlers that are not necessarily instances of
Element
.
keyUpEvent
=
const
EventStreamProvider
<
KeyboardEvent
>
('keyup')
Static factory designed to expose keyup events to event handlers that are not necessarily instances of
Element
.
loadEvent
=
const
EventStreamProvider
<
Event
>
('load')
Static factory designed to expose load events to event handlers that are not necessarily instances of
Element
.
loadedDataEvent
=
const
EventStreamProvider
<
Event
>
('loadeddata')
loadedMetadataEvent
=
const
EventStreamProvider
<
Event
>
('loadedmetadata')
mouseDownEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mousedown')
Static factory designed to expose mousedown events to event handlers that are not necessarily instances of
Element
.
mouseEnterEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mouseenter')
Static factory designed to expose mouseenter events to event handlers that are not necessarily instances of
Element
.
mouseLeaveEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mouseleave')
Static factory designed to expose mouseleave events to event handlers that are not necessarily instances of
Element
.
mouseMoveEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mousemove')
Static factory designed to expose mousemove events to event handlers that are not necessarily instances of
Element
.
mouseOutEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mouseout')
Static factory designed to expose mouseout events to event handlers that are not necessarily instances of
Element
.
mouseOverEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mouseover')
Static factory designed to expose mouseover events to event handlers that are not necessarily instances of
Element
.
mouseUpEvent
=
const
EventStreamProvider
<
MouseEvent
>
('mouseup')
Static factory designed to expose mouseup events to event handlers that are not necessarily instances of
Element
.
mouseWheelEvent
=
const
EventStreamProvider
<
WheelEvent
>
('mousewheel')
pasteEvent
=
const
EventStreamProvider
<
Event
>
('paste')
Static factory designed to expose paste events to event handlers that are not necessarily instances of
Element
.
pauseEvent
=
const
EventStreamProvider
<
Event
>
('pause')
playEvent
=
const
EventStreamProvider
<
Event
>
('play')
playingEvent
=
const
EventStreamProvider
<
Event
>
('playing')
rateChangeEvent
=
const
EventStreamProvider
<
Event
>
('ratechange')
resetEvent
=
const
EventStreamProvider
<
Event
>
('reset')
Static factory designed to expose reset events to event handlers that are not necessarily instances of
Element
.
resizeEvent
=
const
EventStreamProvider
<
Event
>
('resize')
scrollEvent
=
const
EventStreamProvider
<
Event
>
('scroll')
Static factory designed to expose scroll events to event handlers that are not necessarily instances of
Element
.
searchEvent
=
const
EventStreamProvider
<
Event
>
('search')
Static factory designed to expose search events to event handlers that are not necessarily instances of
Element
.
seekedEvent
=
const
EventStreamProvider
<
Event
>
('seeked')
seekingEvent
=
const
EventStreamProvider
<
Event
>
('seeking')
selectEvent
=
const
EventStreamProvider
<
Event
>
('select')
Static factory designed to expose select events to event handlers that are not necessarily instances of
Element
.
selectStartEvent
=
const
EventStreamProvider
<
Event
>
('selectstart')
Static factory designed to expose selectstart events to event handlers that are not necessarily instances of
Element
.
stalledEvent
=
const
EventStreamProvider
<
Event
>
('stalled')
submitEvent
=
const
EventStreamProvider
<
Event
>
('submit')
Static factory designed to expose submit events to event handlers that are not necessarily instances of
Element
.
suspendEvent
=
const
EventStreamProvider
<
Event
>
('suspend')
timeUpdateEvent
=
const
EventStreamProvider
<
Event
>
('timeupdate')
touchCancelEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchcancel')
Static factory designed to expose touchcancel events to event handlers that are not necessarily instances of
Element
.
touchEndEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchend')
Static factory designed to expose touchend events to event handlers that are not necessarily instances of
Element
.
touchEnterEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchenter')
Static factory designed to expose touchenter events to event handlers that are not necessarily instances of
Element
.
touchLeaveEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchleave')
Static factory designed to expose touchleave events to event handlers that are not necessarily instances of
Element
.
touchMoveEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchmove')
Static factory designed to expose touchmove events to event handlers that are not necessarily instances of
Element
.
touchStartEvent
=
const
EventStreamProvider
<
TouchEvent
>
('touchstart')
Static factory designed to expose touchstart events to event handlers that are not necessarily instances of
Element
.
transitionEndEvent
=
const
EventStreamProvider
<
TransitionEvent
>
('transitionend')
volumeChangeEvent
=
const
EventStreamProvider
<
Event
>
('volumechange')
waitingEvent
=
const
EventStreamProvider
<
Event
>
('waiting')
fullscreenChangeEvent
=
const
EventStreamProvider
<
Event
>
('webkitfullscreenchange')
Static factory designed to expose fullscreenchange events to event handlers that are not necessarily instances of
Element
.
fullscreenErrorEvent
=
const
EventStreamProvider
<
Event
>
('webkitfullscreenerror')
Static factory designed to expose fullscreenerror events to event handlers that are not necessarily instances of
Element
.
Static Methods
isTagSupported
(
String
tag
) →
bool
Checks to see if the tag name is supported by the current platform.
Instance Properties
contentEditable
String
read/write
contextMenu
MenuElement
read/write
dir
String
read/write
draggable
bool
read/write
hidden
bool
read/write
lang
String
read/write
spellcheck
bool
read/write
tabIndex
int
read/write
title
String
read/write
translate
bool
read/write
dropzone
String
read/write
attributes
Map
<
String
,
String
>
read/write
children
List
<
Element
>
read/write
classes
CssClassSet
read/write
dataset
Map
<
String
,
String
>
read/write
client
Rectangle
read-only
offset
Rectangle
read-only
xtag
dynamic
read/write
localName
String
read-only
namespaceUri
String
read-only
contentEdge
CssRect
read-only
paddingEdge
CssRect
read-only
borderEdge
CssRect
read-only
marginEdge
CssRect
read-only
documentOffset
Point
read-only
innerHtml
String
read/write
on
ElementEvents
read-only
offsetHeight
int
read-only
offsetLeft
int
read-only
offsetTop
int
read-only
offsetWidth
int
read-only
clientHeight
int
read-only
clientLeft
int
read-only
clientTop
int
read-only
clientWidth
int
read-only
scrollHeight
int
read-only
scrollLeft
int
read/write
scrollTop
int
read/write
scrollWidth
int
read-only
isContentEditable
bool
read-only
className
String
read/write
id
String
read/write
offsetParent
Element
read-only
outerHtml
String
read-only
shadowRoot
ShadowRoot
read-only
style
CssStyleDeclaration
read-only
tagName
String
read-only
nextElementSibling
Element
read-only
previousElementSibling
Element
read-only
onAbort
ElementStream
<
Event
>
read-only
onBeforeCopy
ElementStream
<
Event
>
read-only
onBeforeCut
ElementStream
<
Event
>
read-only
onBeforePaste
ElementStream
<
Event
>
read-only
onBlur
ElementStream
<
Event
>
read-only
onCanPlay
ElementStream
<
Event
>
read-only
onCanPlayThrough
ElementStream
<
Event
>
read-only
onChange
ElementStream
<
Event
>
read-only
onClick
ElementStream
<
MouseEvent
>
read-only
onContextMenu
ElementStream
<
MouseEvent
>
read-only
onCopy
ElementStream
<
Event
>
read-only
onCut
ElementStream
<
Event
>
read-only
onDoubleClick
ElementStream
<
Event
>
read-only
onDrag
ElementStream
<
MouseEvent
>
read-only
onDragEnd
ElementStream
<
MouseEvent
>
read-only
onDragEnter
ElementStream
<
MouseEvent
>
read-only
onDragLeave
ElementStream
<
MouseEvent
>
read-only
onDragOver
ElementStream
<
MouseEvent
>
read-only
onDragStart
ElementStream
<
MouseEvent
>
read-only
onDrop
ElementStream
<
MouseEvent
>
read-only
onDurationChange
ElementStream
<
Event
>
read-only
onEmptied
ElementStream
<
Event
>
read-only
onEnded
ElementStream
<
Event
>
read-only
onError
ElementStream
<
Event
>
read-only
onFocus
ElementStream
<
Event
>
read-only
onInput
ElementStream
<
Event
>
read-only
onInvalid
ElementStream
<
Event
>
read-only
onKeyDown
ElementStream
<
KeyboardEvent
>
read-only
onKeyPress
ElementStream
<
KeyboardEvent
>
read-only
onKeyUp
ElementStream
<
KeyboardEvent
>
read-only
onLoad
ElementStream
<
Event
>
read-only
onLoadedData
ElementStream
<
Event
>
read-only
onLoadedMetadata
ElementStream
<
Event
>
read-only
onMouseDown
ElementStream
<
MouseEvent
>
read-only
onMouseEnter
ElementStream
<
MouseEvent
>
read-only
onMouseLeave
ElementStream
<
MouseEvent
>
read-only
onMouseMove
ElementStream
<
MouseEvent
>
read-only
onMouseOut
ElementStream
<
MouseEvent
>
read-only
onMouseOver
ElementStream
<
MouseEvent
>
read-only
onMouseUp
ElementStream
<
MouseEvent
>
read-only
onMouseWheel
ElementStream
<
WheelEvent
>
read-only
onPaste
ElementStream
<
Event
>
read-only
onPause
ElementStream
<
Event
>
read-only
onPlay
ElementStream
<
Event
>
read-only
onPlaying
ElementStream
<
Event
>
read-only
onRateChange
ElementStream
<
Event
>
read-only
onReset
ElementStream
<
Event
>
read-only
onResize
ElementStream
<
Event
>
read-only
onScroll
ElementStream
<
Event
>
read-only
onSearch
ElementStream
<
Event
>
read-only
onSeeked
ElementStream
<
Event
>
read-only
onSeeking
ElementStream
<
Event
>
read-only
onSelect
ElementStream
<
Event
>
read-only
onSelectStart
ElementStream
<
Event
>
read-only
onStalled
ElementStream
<
Event
>
read-only
onSubmit
ElementStream
<
Event
>
read-only
onSuspend
ElementStream
<
Event
>
read-only
onTimeUpdate
ElementStream
<
Event
>
read-only
onTouchCancel
ElementStream
<
TouchEvent
>
read-only
onTouchEnd
ElementStream
<
TouchEvent
>
read-only
onTouchEnter
ElementStream
<
TouchEvent
>
read-only
onTouchLeave
ElementStream
<
TouchEvent
>
read-only
onTouchMove
ElementStream
<
TouchEvent
>
read-only
onTouchStart
ElementStream
<
TouchEvent
>
read-only
onTransitionEnd
ElementStream
<
TransitionEvent
>
read-only
onVolumeChange
ElementStream
<
Event
>
read-only
onWaiting
ElementStream
<
Event
>
read-only
onFullscreenChange
ElementStream
<
Event
>
read-only
onFullscreenError
ElementStream
<
Event
>
read-only
nodes
List
<
Node
>
Inherited
read/write
baseUri
String
Inherited
read-only
childNodes
List
<
Node
>
Inherited
read-only
firstChild
Node
Inherited
read-only
lastChild
Node
Inherited
read-only
nextNode
Node
Inherited
read-only
nodeName
String
Inherited
read-only
nodeType
int
Inherited
read-only
nodeValue
String
Inherited
read-only
ownerDocument
Document
Inherited
read-only
parent
Element
Inherited
read-only
parentNode
Node
Inherited
read-only
previousNode
Node
Inherited
read-only
text
String
Inherited
read/write
Instance Methods
querySelectorAll
(
String
selectors
) →
ElementList
<
Element
>
Finds all descendent elements of this element that match the specified group of selectors.
query
(
String
relativeSelectors
) →
Element
Alias for
querySelector
. Note this function is deprecated because its semantics will be changing in the future.
queryAll
(
String
relativeSelectors
) →
ElementList
<
Element
>
Alias for
querySelectorAll
. Note this function is deprecated because its semantics will be changing in the future.
getNamespacedAttributes
(
String
namespace
) →
Map
<
String
,
String
>
Gets a map for manipulating the attributes of a particular namespace.
getComputedStyle
( [
String
pseudoElement
] ) →
CssStyleDeclaration
The set of all CSS values applied to this element, including inherited and default values.
appendText
(
String
text
) →
void
Adds the specified text after the last child of this element.
appendHtml
(
String
text
, {
NodeValidator
validator
,
NodeTreeSanitizer
treeSanitizer
} ) →
void
Parses the specified text as HTML and adds the resulting node after the last child of this element.
attached
( ) →
void
Called by the DOM when this element has been inserted into the live document.
detached
( ) →
void
Called by the DOM when this element has been removed from the live document.
enteredView
( ) →
void
Deprecated*: override
attached
instead.
leftView
( ) →
void
Deprecated*: override
detached
instead.
attributeChanged
(
String
name
,
String
oldValue
,
String
newValue
) →
void
Called by the DOM whenever an attribute on this has been changed.
toString
( ) →
String
The string representation of this element.
scrollIntoView
( [
ScrollAlignment
alignment
] ) →
void
Scrolls this element into view.
insertAdjacentHtml
(
String
where
,
String
html
, {
NodeValidator
validator
,
NodeTreeSanitizer
treeSanitizer
} ) →
void
Parses text as an HTML fragment and inserts it into the DOM at the specified location.
matchesWithAncestors
(
String
selectors
) →
bool
Checks if this element or any of its parents match the CSS selectors.
offsetTo
(
Element
parent
) →
Point
Provides the offset of this element's
borderEdge
relative to the specified parent.
createFragment
(
String
html
, {
NodeValidator
validator
,
NodeTreeSanitizer
treeSanitizer
} ) →
DocumentFragment
Create a DocumentFragment from the HTML fragment and ensure that it follows the sanitization rules specified by the validator or treeSanitizer.
setInnerHtml
(
String
html
, {
NodeValidator
validator
,
NodeTreeSanitizer
treeSanitizer
} ) →
void
Parses the HTML fragment and sets it as the contents of this element. This ensures that the generated content follows the sanitization rules specified by the validator or treeSanitizer.
click
( ) →
void
animate
(
Object
effect
, [
Object
timing
] ) →
AnimationPlayer
blur
( ) →
void
createShadowRoot
( ) →
ShadowRoot
focus
( ) →
void
getAnimationPlayers
( ) →
List
<
AnimationPlayer
>
getAttribute
(
String
name
) →
String
getAttributeNS
(
String
namespaceURI
,
String
localName
) →
String
getBoundingClientRect
( ) →
Rectangle
Returns the smallest bounding rectangle that encompasses this element's padding, scrollbar, and border.
getClientRects
( ) →
List
<
Rectangle
>
Returns a list of bounding rectangles for each box associated with this element.
getDestinationInsertionPoints
( ) →
List
<
Node
>
Returns a list of shadow DOM insertion points to which this element is distributed.
getElementsByClassName
(
String
classNames
) →
List
<
Node
>
Returns a list of nodes with the given class name inside this element.
insertAdjacentElement
(
String
where
,
Element
element
) →
Element
insertAdjacentText
(
String
where
,
String
text
) →
void
matches
(
String
selectors
) →
bool
requestFullscreen
( ) →
void
requestPointerLock
( ) →
void
setAttribute
(
String
name
,
String
value
) →
void
setAttributeNS
(
String
namespaceURI
,
String
qualifiedName
,
String
value
) →
void
remove
( ) →
void
Removes this node from the DOM.
querySelector
(
String
selectors
) →
Element
Finds the first descendant element of this element that matches the specified group of selectors.
addEventListener
Inherited
(
String
type
,
dynamic
listener
(
Event
event
)
, [
bool
useCapture
] ) →
void
removeEventListener
Inherited
(
String
type
,
dynamic
listener
(
Event
event
)
, [
bool
useCapture
] ) →
void
dispatchEvent
Inherited
(
Event
event
) →
bool
replaceWith
Inherited
(
Node
otherNode
) →
Node
Replaces this node with another node.
insertAllBefore
Inherited
(
Iterable
<
Node
>
newNodes
,
Node
refChild
) →
Node
Inserts all of the nodes into this node directly before refChild.
append
Inherited
(
Node
newChild
) →
Node
Adds a node to the end of the child
nodes
list of this node.
clone
Inherited
(
bool
deep
) →
Node
Returns a copy of this node.
contains
Inherited
(
Node
other
) →
bool
Returns true if this node contains the specified node.
hasChildNodes
Inherited
( ) →
bool
Returns true if this node has any children.
insertBefore
Inherited
(
Node
newChild
,
Node
refChild
) →
Node
Inserts all of the nodes into this node directly before refChild.