software-tools-books / js4ds

JavaScript for Data Science
https://third-bit.com/js4ds/
Other
187 stars 32 forks source link

Bug/typo in "Manipulating pages" chapter #228

Open lucio-cornejo opened 1 year ago

lucio-cornejo commented 1 year ago

In the section "Sortable Lists" of the "Manipulating pages" chapter, the first JavaScript code presents a typo, using document.querySelectorAll('#sorted')) where it should be (as later explained in the same section) document.querySelectorAll('.sorted')).

After changing that typo, the initial example (using onload for the body) does produce sorted lists, which the book emphasises should not have happened still (but only after we use the DOMContentLoaded event).

Due to the fact that it's not always the case that the DOMContentLoaded event occurs before the load one, a possible way to fix this example/section could be to change the typo (using .sorted) but not including the onload attribute for the body element.