Code cleanup + additional debugging stmts in DOMDiff.js

* Ported over cleanup and debugging code from the abandoned patch
  https://gerrit.wikimedia.org/r/#/c/59448/

* No change in any test results.

Change-Id: I1a6efc6beb036ea2f8fd2e04b79677433404efc6
Merge "Code cleanup + additional debugging stmts in DOMDiff.js"