feat(scope): move domWrite and domRead from RootScope to Scope

This PR moves `domWrite` and `domRead` from `RootScope` to `Scope`. This changes `domWrite` and `domRead` into trees of functions. This allows us to run all DOM operations bottom-up, which solves a few problems (e.g, #1161).

Closes #1161