Skip to content

Commit

Permalink
WIP make sure $el contains on the el
Browse files Browse the repository at this point in the history
Alternative solution to #3421

This is a WIP and needs tests, but I think doing this check once on `_ensureElement` is better than within `attachHtml`  And it makes `this.$el` more consistent and matches what happens in the region constructor

This still needs a test
  • Loading branch information
paulfalgout committed Aug 14, 2017
1 parent 1962fbb commit 0fa0480
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const Region = MarionetteObject.extend({
if (!_.isObject(this.el)) {
this.$el = this.getEl(this.el);
this.el = this.$el[0];
// Make sure the $el contains only the el
this.$el = this.getEl(this.el);
}

if (!this.$el || this.$el.length === 0) {
Expand Down Expand Up @@ -242,7 +244,7 @@ const Region = MarionetteObject.extend({
// Override this method to change how the new view is appended to the `$el` that the
// region is managing
attachHtml(view) {
this.Dom.appendContents(this.el, view.el, {_$contents: view.$el});
this.Dom.appendContents(this.el, view.el, {_$el: this.$el, _$contents: view.$el});
},

// Destroy the current view, if there is one. If there is no current view, it does
Expand Down

0 comments on commit 0fa0480

Please sign in to comment.