marionettejs/backbone.marionette — pull request #1705 by jfairbank (2014-08-02 00:31:19+00:00)
Title: Refactor Regions mainly for LayoutView

This should fix #1673 and #1685 but comes with somewhat drastic changes. As an added bonus, this does remove the ugly `getEl` override in `Region.buildRegion`.

These changes fix #1685:

* Set a `_parentEl` option in the `Region` constructor. `Region#getEl` now just checks for this property and uses it if it's available.
* Initialize regions in `LayoutView` **AFTER** calling the `ItemView` constructor. This ensures that the `LayoutView` element is available for the new `Region#getEl` implementation. This could have some unintended consequences that I'm not aware of, though. All tests pass regardless.

These changes fix #1673:

* Keep a reference to the original `el` option in the `Region` constructor as `_optionEl`.
* In `Region#reset` set `this.el` back to the original `_optionEl` instead of the `$el` selector. This allows the selector to not prepend the `parentEl` selector multiple times. Also, this allows `Regions` instantiated with an existing HTML node or jQuery object to be reset.

Overall, this felt like the best balance between being least intrusive while still cleaning up some code. Some of these changes may be too much for BC, so I definitely need some eyes on this one.