Skip to content

Commit

Permalink
feat(better fastboot compat) render in place in Fastboot
Browse files Browse the repository at this point in the history
  • Loading branch information
kybishop committed Jul 9, 2017
1 parent ef7fe9d commit 07e4b81
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions addon/components/ember-popper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default Ember.Component.extend({
// Classes to be applied to the popper element
popperClass: null,

// The popper element needs to be moved higher in the DOM tree to avoid z-index issues.
// See the block-comment in the template for more details.
popperContainer: Ember.computed({
set(_, value) {
if (value instanceof Element) {
Expand All @@ -38,16 +40,30 @@ export default Ember.Component.extend({
},

get() {
// The popper element needs to be moved higher in the DOM tree to avoid z-index issues.
// See the block-comment in the template for more details.
// There is no self.document in Fastboot, so we cannot access the document body. We avoid this
// issue by always rendering in place when in Fastboot.
return self.document ? self.document.body : '';
}
}),

// If `true`, the popper element will not be moved to popperContainer. WARNING: This can cause
// z-index issues where your popper will be overlapped by DOM elements that aren't nested as
// deeply in the DOM tree.
renderInPlace: false,
renderInPlace: Ember.computed({
set(_, value) {
// self.document is undefined in Fastboot, so we always render in place when it is undefined.
if (self.document) {
return value;
}

return true;
},

get() {
// self.document is undefined in Fastboot, so we always render in place when it is undefined.
return self.document ? false : true;
}
}),

// The element the popper will target. If left blank, will be set to the ember-popper's parent.
target: null,
Expand Down

0 comments on commit 07e4b81

Please sign in to comment.