The browser and the DOM

This part of the JavaScript course goes into the browser: a page gets window and document, and the lessons here work on the DOM tree that document exposes. Elements are selected with querySelector and its older methods, their text, attributes and classes are changed, and nodes are created and removed to render a list from an array. Events follow with bubbling and delegation, then a form and its validity flags, a fetch from the page, and storage and history kept through a reload.

10.1 What the browser gives: window and the DOM window and document, the DOM tree walked element by element, the circular window that JSON cannot write, and the same page code in a browser and in jsdom Open 10.2 Selecting elements on a page getElementById, querySelector and querySelectorAll with its static NodeList, closest and matches, and attribute, class and position selectors Open 10.3 Changing content and attributes textContent against innerHTML and the user text that turns into elements, classList with add, remove, toggle and replace, and data attributes through dataset Open 10.4 Creating and removing nodes createElement and append, insertBefore with prepend and after, remove against removeChild, replaceChildren, and a list rendered from an array Open 10.5 Events: addEventListener, bubbling and delegation a listener and the event object, dispatchEvent on a page without a user, the bubble and capture phases, stopPropagation, and one delegated listener for a list Open 10.6 Forms and validation input values and valueAsNumber, checkValidity with the validity flags, a submit handler that reports every problem, and FormData as one object Open 10.7 fetch in the browser the fetch of Node.js handed to the page, a relative path against window.location, status codes and ok, a JSON POST, and the rejection of a request that never arrived Open 10.8 Storage and history localStorage with its strings and keys, a draft saved and restored, pushState and replaceState with popstate, and a stored value that is no longer JSON Open

Lessons