DART :: lastElementChild and firstElementChild DOM

From new DART versions some native DOM methods have been marked as deprecated, letting them only if You have serious reasons to use it.

Examples of these methods are lastElementChild and firstElementChild.

On Element Interface you can see them.

/** @domName Element.firstElementChild */
final Element $dom_firstElementChild;

/** @domName Element.lastElementChild */
final Element $dom_lastElementChild;

However, if we can use native DART methods we must avoid to use $dom_, as we mentioned in the DART discuss (https://groups.google.com/a/dartlang.org/d/msg/misc/7lh8T49ntjo/MQUVWuGnqqoJ ), they can be removed at any time and our code won’t work properly.

If you need firstElementChild or lastElementChild you can do using builtin methods on DART.

I leave you an simple and useful example.

// I get myDiv from the document.
DivElement myDiv = document.quer(‘#myDiv’);
// I get the last element.
myDiv.elements.last();
// I get the first element.
myDiv.elements.first;


 Google+