07 Mar 2014, 23:19
Generic-user-small

Michael Keisu (1 post)

Bought this book just recently, it’s supposed to have been updated for 1.1. Yet the very first example uses deprecated code in document.query() new way is querySelector( .. )

Is this book updated or not?

10 Mar 2014, 02:19
Chris_strom_headshot_200_pragsmall

Chris Strom (78 posts)

Heh. tl;dr: These are deprecated only to be replaced with slightly better versions of the same methods, so I’m intentionally leaving them in the book.

The query() and queryAll() methods of Element are deprecated because they will be replaced with… query() and queryAll(). The current implementations do mimic the querySelector() implementations of “regular” DOM methods. The Dart language developers figured that the names were silly—why add all the extra typing of the word “selector” every time we want to the query the DOM. I fully agree.

The deprecation came about because there is now a proposal to add query() and queryAll() to the “regular” DOM specification. The semantics of these two will be nearly identical (yay standards bodies!), but… will produce live node lists instead of a static list of elements (there may be some other minor differences as well). Live node lists are almost always better, so I am eager for the change.

Bottom line: I am intentionally leaving these in place in an effort to better position the book for current Dart and future Dart. But it seems worth adding a note in the book, which I will do :)

Further reading: https://groups.google.com/a/dartlang.org/d/msg/web-ui/dJnz6DbyPbs/VIWDzih_-XQJ

  You must be logged in to comment