Enable tpl-encap in some fostered tpl-content scenarios.

* The following snippet wouldn't RT because the templates
  wouldn't be encapsulated correctly.  The encap fails because
  the div inside the table (2 tpls + foo) gets fostered out and
  the div doesn't get a valid DSR (since it is tpl-content).

     <table>
     {{echo|<div>}}
     foo
     {{echo|</div>}}
     </table>

* Existing fostering-detection code couldn't handle this case.
  Fixed it by adding a fostered flag on DOM nodes when we can
  detect it, and using that flag to fix up encapsulation even
  when DSR is missing.

* Better documented the code.

* The above snippet now RTs with this fix.  en:Dogma studio, the
  page from which this snippet was extracted also RTs better now.

* No change in parser test results (TODO: Add the above snippet
  as a new test.)

* Unrelated fix: Fixed a JSHint warning.

Change-Id: Ib769020f51515f1ed472a06215b086597c895a72
Merge "Enable tpl-encap in some fostered tpl-content scenarios."