diff --git a/.travis.yml b/.travis.yml index 42a1029..d83b4e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ env: matrix: # we recommend new addons test the current and previous LTS # as well as latest stable release (bonus points to beta/canary) - - EMBER_TRY_SCENARIO=ember-1.11 - EMBER_TRY_SCENARIO=ember-1.13 - EMBER_TRY_SCENARIO=ember-lts-2.4 - EMBER_TRY_SCENARIO=ember-lts-2.8 diff --git a/addon/components/-ember-popper-legacy.js b/addon/components/-ember-popper-legacy.js deleted file mode 100644 index 349ffd1..0000000 --- a/addon/components/-ember-popper-legacy.js +++ /dev/null @@ -1,84 +0,0 @@ -import { addObserver, removeObserver } from '@ember/object/observers'; - -import EmberPopperBase from './ember-popper-base'; -import { computed } from 'ember-decorators/object'; - -import { tagName } from 'ember-decorators/component'; - -import { GTE_EMBER_1_13 } from 'ember-compatibility-helpers'; - -@tagName('div') -export default class EmberPopper extends EmberPopperBase { - - // ================== LIFECYCLE HOOKS ================== - - didInsertElement() { - this._initialParentNode = this.element.parentNode; - - if (!GTE_EMBER_1_13) { - addObserver(this, 'eventsEnabled', this, this._updatePopper); - addObserver(this, 'modifiers', this, this._updatePopper); - addObserver(this, 'onCreate', this, this._updatePopper); - addObserver(this, 'onUpdate', this, this._updatePopper); - addObserver(this, 'placement', this, this._updatePopper); - addObserver(this, 'popperContainer', this, this._updatePopper); - addObserver(this, 'popperTarget', this, this._updatePopper); - addObserver(this, 'registerAPI', this, this._updatePopper); - addObserver(this, 'renderInPlace', this, this._updatePopper); - - super.didRender(...arguments); - } - } - - willDestroyElement() { - super.willDestroyElement(...arguments); - - if (!GTE_EMBER_1_13) { - removeObserver(this, 'eventsEnabled', this, this._updatePopper); - removeObserver(this, 'modifiers', this, this._updatePopper); - removeObserver(this, 'onCreate', this, this._updatePopper); - removeObserver(this, 'onUpdate', this, this._updatePopper); - removeObserver(this, 'placement', this, this._updatePopper); - removeObserver(this, 'popperContainer', this, this._updatePopper); - removeObserver(this, 'popperTarget', this, this._updatePopper); - removeObserver(this, 'registerAPI', this, this._updatePopper); - removeObserver(this, 'renderInPlace', this, this._updatePopper); - } - - const element = this._getPopperElement(); - - if (element.parentNode !== this._initialParentNode) { - element.parentNode.removeChild(element); - } - } - - // ================== PRIVATE IMPLEMENTATION DETAILS ================== - - _updatePopper() { - const element = this._getPopperElement(); - const popperContainer = this.get('_popperContainer'); - const renderInPlace = this.get('_renderInPlace'); - - // If renderInPlace is false, move the element to the popperContainer to avoid z-index issues. - // See renderInPlace for more details. - if (renderInPlace === false && element.parentNode !== popperContainer) { - popperContainer.appendChild(element); - } - - super._updatePopper(); - } - - _getPopperElement() { - return this.element; - } - - @computed() - get _popperHash() { - return { - disableEventListeners: this.disableEventListeners.bind(this), - enableEventListeners: this.enableEventListeners.bind(this), - scheduleUpdate: this.scheduleUpdate.bind(this), - update: this.update.bind(this) - }; - } -} diff --git a/addon/components/ember-popper-base.js b/addon/components/ember-popper-base.js deleted file mode 100644 index 0a8c612..0000000 --- a/addon/components/ember-popper-base.js +++ /dev/null @@ -1,344 +0,0 @@ -import { assert } from '@ember/debug'; - -import Component from '@ember/component'; - -import { action, computed } from 'ember-decorators/object'; -import { tagName } from 'ember-decorators/component'; - -import { argument } from '@ember-decorators/argument'; -import { type, unionOf, optional } from '@ember-decorators/argument/type'; -import { Action, Element } from '@ember-decorators/argument/types'; - -import { scheduler as raf } from 'ember-raf-scheduler'; - -import layout from '../templates/components/ember-popper'; - -const Selector = unionOf('string', Element); - -@tagName('') -export default class EmberPopperBase extends Component { - layout = layout - - // ================== PUBLIC CONFIG OPTIONS ================== - - /** - * Whether event listeners, resize and scroll, for repositioning the popper are initially enabled. - */ - @argument({ defaultIfUndefined: true }) - @type('boolean') - eventsEnabled = true - - /** - * Modifiers that will be merged into the Popper instance's options hash. - * https://popper.js.org/popper-documentation.html#Popper.DEFAULTS - */ - @argument - @type(optional('object')) - modifiers = null - - /** - * onCreate callback merged (if present) into the Popper instance's options hash. - * https://popper.js.org/popper-documentation.html#Popper.Defaults.onCreate - */ - @argument - @type(optional(Function)) - onCreate = null - - /** - * onUpdate callback merged (if present) into the Popper instance's options hash. - * https://popper.js.org/popper-documentation.html#Popper.Defaults.onUpdate - */ - @argument - @type(optional(Function)) - onUpdate = null - - /** - * Placement of the popper. One of ['top', 'right', 'bottom', 'left']. - */ - @argument({ defaultIfUndefined: true }) - @type('string') - placement = 'bottom' - - /** - * 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. `.ember-application` is applied - * to the root element of the ember app by default, so we move it up to there. - */ - @argument({ defaultIfUndefined: true }) - @type(Selector) - popperContainer = '.ember-application' - - /** - * The element the popper will target. If left blank, will be set to the ember-popper's parent. - */ - @argument - @type(optional(Selector)) - popperTarget = null - - /** - * An optional function to be called when a new target is located. - * The target is passed in as an argument to the function. - */ - @argument - @type(optional(Action)) - registerAPI = null - - /** - * 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. - */ - @argument({ defaultIfUndefined: true }) - @type('boolean') - renderInPlace = false - - // ================== PRIVATE PROPERTIES ================== - - /** - * Tracks current/previous state of `_renderInPlace`. - */ - _didRenderInPlace = false - - /** - * Tracks current/previous value of `eventsEnabled` option - */ - _eventsEnabled = null - - /** - * Parent of the element on didInsertElement, before it may have been moved - */ - _initialParentNode = null - - /** - * Tracks current/previous value of `modifiers` option - */ - _modifiers = null - - /** - * Tracks current/previous value of `onCreate` callback - */ - _onCreate = null - - /** - * Tracks current/previous value of `onUpdate` callback - */ - _onUpdate = null - - /** - * Tracks current/previous value of `placement` option - */ - _placement = null - - /** - * Set in didInsertElement() once the Popper is initialized. - * Passed to consumers via a named yield. - */ - _popper = null - - /** - * Tracks current/previous value of popper target - */ - _popperTarget = null - - /** - * Public API of the popper sent to external components in `registerAPI` - */ - _publicAPI = null - - /** - * ID for the requestAnimationFrame used for updates, used to cancel - * the RAF on component destruction - */ - _updateRAF = null - - // ================== LIFECYCLE HOOKS ================== - - didRender() { - this._updatePopper(); - } - - willDestroyElement() { - super.willDestroyElement(...arguments); - - this._popper.destroy(); - raf.forget(this._updateRAF); - } - - /** - * ================== ACTIONS ================== - */ - - @action - update() { - this._popper.update(); - } - - @action - scheduleUpdate() { - if (this._updateRAF !== null) { - return; - } - - this._updateRAF = raf.schedule('affect', () => { - this._updateRAF = null; - this._popper.update(); - }); - } - - @action - enableEventListeners() { - this._popper.enableEventListeners(); - } - - @action - disableEventListeners() { - this._popper.disableEventListeners(); - } - - // ================== PRIVATE IMPLEMENTATION DETAILS ================== - - _updatePopper() { - if (this.isDestroying || this.isDestroyed) { - return; - } - - const eventsEnabled = this.get('eventsEnabled'); - const modifiers = this.get('modifiers'); - const onCreate = this.get('onCreate'); - const onUpdate = this.get('onUpdate'); - const placement = this.get('placement'); - const popperTarget = this._getPopperTarget(); - const renderInPlace = this.get('_renderInPlace'); - - // Compare against previous values to see if anything has changed - const didChange = renderInPlace !== this._didRenderInPlace - || popperTarget !== this._popperTarget - || eventsEnabled !== this._eventsEnabled - || modifiers !== this._modifiers - || placement !== this._placement - || onCreate !== this._onCreate - || onUpdate !== this._onUpdate; - - if (didChange === true) { - if (this._popper !== null) { - this._popper.destroy(); - } - - const popperElement = this._getPopperElement(); - - // Store current values to check against on updates - this._didRenderInPlace = renderInPlace; - this._eventsEnabled = eventsEnabled; - this._modifiers = modifiers; - this._onCreate = onCreate; - this._onUpdate = onUpdate; - this._placement = placement; - this._popperTarget = popperTarget; - - const options = { - eventsEnabled, - modifiers, - placement - }; - - if (onCreate) { - assert('onCreate of ember-popper must be a function', typeof onCreate === 'function'); - options.onCreate = onCreate; - } - - if (onUpdate) { - assert('onUpdate of ember-popper must be a function', typeof onUpdate === 'function'); - options.onUpdate = onUpdate; - } - - this._popper = new Popper(popperTarget, popperElement, options); - - // Execute the registerAPI hook last to ensure the Popper is initialized on the target - if (this.get('registerAPI') !== null) { - this.sendAction('registerAPI', this._getPublicAPI()); - } - } - } - - /** - * Used to get the popper element - */ - _getPopperElement() { - return self.document.getElementById(this.id); - } - - /** - * Used to get the popper target whenever updating the Popper - */ - _getPopperTarget() { - const targetSelector = this.get('popperTarget'); - - let popperTarget; - - // If there is no target, set the target to the parent element - if (!targetSelector) { - popperTarget = this._initialParentNode; - } else if (targetSelector instanceof Element) { - popperTarget = targetSelector; - } else { - const nodes = document.querySelectorAll(targetSelector); - - assert(`ember-popper with target selector "${targetSelector}" found ${nodes.length}` - + 'possible targets when there should be exactly 1', nodes.length === 1); - - popperTarget = nodes[0]; - } - - return popperTarget; - } - - _getPublicAPI() { - if (this._publicAPI === null) { - // bootstrap the public API with fields that are guaranteed to be static, - // such as imperative actions - this._publicAPI = { - disableEventListeners: this.disableEventListeners.bind(this), - enableEventListeners: this.enableEventListeners.bind(this), - scheduleUpdate: this.scheduleUpdate.bind(this), - update: this.update.bind(this) - }; - } - - this._publicAPI.popperElement = this._getPopperElement(); - this._publicAPI.popperTarget = this._popperTarget; - - return this._publicAPI; - } - - @computed('_renderInPlace', 'popperContainer') - get _popperContainer() { - const renderInPlace = this.get('_renderInPlace'); - const maybeContainer = this.get('popperContainer'); - - let popperContainer; - - if (renderInPlace) { - popperContainer = this._initialParentNode; - } else if (maybeContainer instanceof Element) { - popperContainer = maybeContainer; - } else if (typeof maybeContainer === 'string') { - const selector = maybeContainer; - const possibleContainers = self.document.querySelectorAll(selector); - - assert(`ember-popper with popperContainer selector "${selector}" found ` - + `${possibleContainers.length} possible containers when there should be exactly 1`, - possibleContainers.length === 1); - - popperContainer = possibleContainers[0]; - } - - return popperContainer; - } - - @computed('renderInPlace') - get _renderInPlace() { - // self.document is undefined in Fastboot, so we have to render in - // place for the popper to show up at all. - return self.document ? !!this.get('renderInPlace') : true; - } -} diff --git a/addon/components/ember-popper.js b/addon/components/ember-popper.js index c629314..94daa65 100644 --- a/addon/components/ember-popper.js +++ b/addon/components/ember-popper.js @@ -1,7 +1,156 @@ -import EmberPopperBase from './ember-popper-base'; +import { assert } from '@ember/debug'; + +import Component from '@ember/component'; import { guidFor } from '@ember/object/internals'; -export default class EmberPopper extends EmberPopperBase { +import { action, computed } from 'ember-decorators/object'; +import { tagName } from 'ember-decorators/component'; + +import { argument } from '@ember-decorators/argument'; +import { type, unionOf, optional } from '@ember-decorators/argument/type'; +import { Action, Element } from '@ember-decorators/argument/types'; + +import { scheduler as raf } from 'ember-raf-scheduler'; + +import layout from '../templates/components/ember-popper'; + +const Selector = unionOf('string', Element); + +@tagName('') +export default class EmberPopperBase extends Component { + layout = layout + + // ================== PUBLIC CONFIG OPTIONS ================== + + /** + * Whether event listeners, resize and scroll, for repositioning the popper are initially enabled. + */ + @argument({ defaultIfUndefined: true }) + @type('boolean') + eventsEnabled = true + + /** + * Modifiers that will be merged into the Popper instance's options hash. + * https://popper.js.org/popper-documentation.html#Popper.DEFAULTS + */ + @argument + @type(optional('object')) + modifiers = null + + /** + * onCreate callback merged (if present) into the Popper instance's options hash. + * https://popper.js.org/popper-documentation.html#Popper.Defaults.onCreate + */ + @argument + @type(optional(Function)) + onCreate = null + + /** + * onUpdate callback merged (if present) into the Popper instance's options hash. + * https://popper.js.org/popper-documentation.html#Popper.Defaults.onUpdate + */ + @argument + @type(optional(Function)) + onUpdate = null + + /** + * Placement of the popper. One of ['top', 'right', 'bottom', 'left']. + */ + @argument({ defaultIfUndefined: true }) + @type('string') + placement = 'bottom' + + /** + * 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. `.ember-application` is applied + * to the root element of the ember app by default, so we move it up to there. + */ + @argument({ defaultIfUndefined: true }) + @type(Selector) + popperContainer = '.ember-application' + + /** + * The element the popper will target. If left blank, will be set to the ember-popper's parent. + */ + @argument + @type(optional(Selector)) + popperTarget = null + + /** + * An optional function to be called when a new target is located. + * The target is passed in as an argument to the function. + */ + @argument + @type(optional(Action)) + registerAPI = null + + /** + * 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. + */ + @argument({ defaultIfUndefined: true }) + @type('boolean') + renderInPlace = false + + // ================== PRIVATE PROPERTIES ================== + + /** + * Tracks current/previous state of `_renderInPlace`. + */ + _didRenderInPlace = false + + /** + * Tracks current/previous value of `eventsEnabled` option + */ + _eventsEnabled = null + + /** + * Parent of the element on didInsertElement, before it may have been moved + */ + _initialParentNode = null + + /** + * Tracks current/previous value of `modifiers` option + */ + _modifiers = null + + /** + * Tracks current/previous value of `onCreate` callback + */ + _onCreate = null + + /** + * Tracks current/previous value of `onUpdate` callback + */ + _onUpdate = null + + /** + * Tracks current/previous value of `placement` option + */ + _placement = null + + /** + * Set in didInsertElement() once the Popper is initialized. + * Passed to consumers via a named yield. + */ + _popper = null + + /** + * Tracks current/previous value of popper target + */ + _popperTarget = null + + /** + * Public API of the popper sent to external components in `registerAPI` + */ + _publicAPI = null + + /** + * ID for the requestAnimationFrame used for updates, used to cancel + * the RAF on component destruction + */ + _updateRAF = null // ================== LIFECYCLE HOOKS ================== @@ -17,4 +166,193 @@ export default class EmberPopper extends EmberPopperBase { super.didInsertElement(...arguments); } + + didRender() { + this._updatePopper(); + } + + willDestroyElement() { + super.willDestroyElement(...arguments); + + this._popper.destroy(); + raf.forget(this._updateRAF); + } + + /** + * ================== ACTIONS ================== + */ + + @action + update() { + this._popper.update(); + } + + @action + scheduleUpdate() { + if (this._updateRAF !== null) { + return; + } + + this._updateRAF = raf.schedule('affect', () => { + this._updateRAF = null; + this._popper.update(); + }); + } + + @action + enableEventListeners() { + this._popper.enableEventListeners(); + } + + @action + disableEventListeners() { + this._popper.disableEventListeners(); + } + + // ================== PRIVATE IMPLEMENTATION DETAILS ================== + + _updatePopper() { + if (this.isDestroying || this.isDestroyed) { + return; + } + + const eventsEnabled = this.get('eventsEnabled'); + const modifiers = this.get('modifiers'); + const onCreate = this.get('onCreate'); + const onUpdate = this.get('onUpdate'); + const placement = this.get('placement'); + const popperTarget = this._getPopperTarget(); + const renderInPlace = this.get('_renderInPlace'); + + // Compare against previous values to see if anything has changed + const didChange = renderInPlace !== this._didRenderInPlace + || popperTarget !== this._popperTarget + || eventsEnabled !== this._eventsEnabled + || modifiers !== this._modifiers + || placement !== this._placement + || onCreate !== this._onCreate + || onUpdate !== this._onUpdate; + + if (didChange === true) { + if (this._popper !== null) { + this._popper.destroy(); + } + + const popperElement = this._getPopperElement(); + + // Store current values to check against on updates + this._didRenderInPlace = renderInPlace; + this._eventsEnabled = eventsEnabled; + this._modifiers = modifiers; + this._onCreate = onCreate; + this._onUpdate = onUpdate; + this._placement = placement; + this._popperTarget = popperTarget; + + const options = { + eventsEnabled, + modifiers, + placement + }; + + if (onCreate) { + assert('onCreate of ember-popper must be a function', typeof onCreate === 'function'); + options.onCreate = onCreate; + } + + if (onUpdate) { + assert('onUpdate of ember-popper must be a function', typeof onUpdate === 'function'); + options.onUpdate = onUpdate; + } + + this._popper = new Popper(popperTarget, popperElement, options); + + // Execute the registerAPI hook last to ensure the Popper is initialized on the target + if (this.get('registerAPI') !== null) { + this.sendAction('registerAPI', this._getPublicAPI()); + } + } + } + + /** + * Used to get the popper element + */ + _getPopperElement() { + return self.document.getElementById(this.id); + } + + /** + * Used to get the popper target whenever updating the Popper + */ + _getPopperTarget() { + const targetSelector = this.get('popperTarget'); + + let popperTarget; + + // If there is no target, set the target to the parent element + if (!targetSelector) { + popperTarget = this._initialParentNode; + } else if (targetSelector instanceof Element) { + popperTarget = targetSelector; + } else { + const nodes = document.querySelectorAll(targetSelector); + + assert(`ember-popper with target selector "${targetSelector}" found ${nodes.length}` + + 'possible targets when there should be exactly 1', nodes.length === 1); + + popperTarget = nodes[0]; + } + + return popperTarget; + } + + _getPublicAPI() { + if (this._publicAPI === null) { + // bootstrap the public API with fields that are guaranteed to be static, + // such as imperative actions + this._publicAPI = { + disableEventListeners: this.disableEventListeners.bind(this), + enableEventListeners: this.enableEventListeners.bind(this), + scheduleUpdate: this.scheduleUpdate.bind(this), + update: this.update.bind(this) + }; + } + + this._publicAPI.popperElement = this._getPopperElement(); + this._publicAPI.popperTarget = this._popperTarget; + + return this._publicAPI; + } + + @computed('_renderInPlace', 'popperContainer') + get _popperContainer() { + const renderInPlace = this.get('_renderInPlace'); + const maybeContainer = this.get('popperContainer'); + + let popperContainer; + + if (renderInPlace) { + popperContainer = this._initialParentNode; + } else if (maybeContainer instanceof Element) { + popperContainer = maybeContainer; + } else if (typeof maybeContainer === 'string') { + const selector = maybeContainer; + const possibleContainers = self.document.querySelectorAll(selector); + + assert(`ember-popper with popperContainer selector "${selector}" found ` + + `${possibleContainers.length} possible containers when there should be exactly 1`, + possibleContainers.length === 1); + + popperContainer = possibleContainers[0]; + } + + return popperContainer; + } + + @computed('renderInPlace') + get _renderInPlace() { + // self.document is undefined in Fastboot, so we have to render in + // place for the popper to show up at all. + return self.document ? !!this.get('renderInPlace') : true; + } } diff --git a/addon/templates/components/-ember-popper-legacy-1.11.hbs b/addon/templates/components/-ember-popper-legacy-1.11.hbs deleted file mode 100644 index 7b2e778..0000000 --- a/addon/templates/components/-ember-popper-legacy-1.11.hbs +++ /dev/null @@ -1 +0,0 @@ -{{yield _popperHash}} diff --git a/addon/templates/components/-ember-popper-legacy.hbs b/addon/templates/components/-ember-popper-legacy.hbs deleted file mode 100644 index 3fd9715..0000000 --- a/addon/templates/components/-ember-popper-legacy.hbs +++ /dev/null @@ -1,6 +0,0 @@ -{{yield (hash - disableEventListeners=(action 'disableEventListeners') - enableEventListeners=(action 'enableEventListeners') - scheduleUpdate=(action 'scheduleUpdate') - update=(action 'update') -)}} diff --git a/addon/templates/components/ember-popper.hbs b/addon/templates/components/ember-popper.hbs index 3762fa3..cc64d6e 100644 --- a/addon/templates/components/ember-popper.hbs +++ b/addon/templates/components/ember-popper.hbs @@ -1,30 +1,17 @@ {{unbound _parentFinder}} -{{#if renderInPlace}} +{{!-- Elements that exist deep within the document tree are given an implicitly lower z-index + value than elements that aren't as deep in the tree; this has the effect of hiding our + ember-popper behind less-nested elements. Due to the way z-indexing works, we cannot simply + add a higher z-index value to our ember-popper. To avoid this issue, we render the element + on the document body, giving it the highest default z-index value. --}} +{{#maybe-in-element _popperContainer renderInPlace}}
{{yield (hash - disableEventListeners=(action 'disableEventListeners') - enableEventListeners=(action 'enableEventListeners') - scheduleUpdate=(action 'scheduleUpdate') - update=(action 'update') - )}} + disableEventListeners=(action 'disableEventListeners') + enableEventListeners=(action 'enableEventListeners') + scheduleUpdate=(action 'scheduleUpdate') + update=(action 'update') + )}}
-{{else}} - {{!-- Elements that exist deep within the document tree are given an implicitly lower z-index - value than elements that aren't as deep in the tree; this has the effect of hiding our - ember-popper behind less-nested elements. Due to the way z-indexing works, we cannot simply - add a higher z-index value to our ember-popper. To avoid this issue, we render the element - on the document body, giving it the highest default z-index value. --}} - - {{#-in-element _popperContainer}} - {{!-- Add a wrapper around the yielded block so we have something for the Popper to target --}} -
- {{yield (hash - disableEventListeners=(action 'disableEventListeners') - enableEventListeners=(action 'enableEventListeners') - scheduleUpdate=(action 'scheduleUpdate') - update=(action 'update') - )}} -
- {{/-in-element}} -{{/if}} +{{/maybe-in-element}} diff --git a/config/ember-try.js b/config/ember-try.js index 507355f..55c09d9 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -2,28 +2,6 @@ module.exports = { useYarn: true, scenarios: [ - { - name: 'ember-1.11', - bower: { - dependencies: { - 'ember': '~1.11.0', - 'ember-cli-shims': '0.0.6' - }, - resolutions: { - 'ember': '~1.11.0', - 'ember-cli-shims': '0.0.6' - } - }, - npm: { - devDependencies: { - 'ember-cli-fastboot': null, - 'ember-cli-shims': null, - 'ember-native-dom-event-dispatcher': null, - 'ember-source': null, - 'fastboot': null - } - } - }, { name: 'ember-1.13', bower: { diff --git a/index.js b/index.js index 242b1b6..c2ca5f6 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,8 @@ /* eslint-env node */ 'use strict'; -const Funnel = require('broccoli-funnel'); const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck'); const fastbootTransform = require('fastboot-transform'); -const VersionChecker = require('ember-cli-version-checker'); module.exports = { name: 'ember-popper', @@ -33,10 +31,6 @@ module.exports = { app = app.parent; } - const checker = new VersionChecker(app); - - this._emberChecker = checker.forEmber(); - this._env = app.env; this._setupBabelOptions(app.env); }, @@ -57,61 +51,6 @@ module.exports = { } this._hasSetupBabelOptions = true; - }, - - treeForAddonTemplates(tree) { - const _emberChecker = this._emberChecker; - - if (_emberChecker.gte('2.10.0')) { - tree = new Funnel(tree, { - exclude: [ - 'components/-ember-popper-legacy.hbs', - 'components/-ember-popper-legacy-1.11.hbs' - ] - }); - } else if (_emberChecker.gte('1.13.0')) { - tree = new Funnel(tree, { - exclude: [ - 'components/ember-popper.hbs', - 'components/-ember-popper-legacy-1.11.hbs' - ], - getDestinationPath: replaceLegacyPath - }); - } else { - tree = new Funnel(tree, { - exclude: [ - 'components/ember-popper.hbs', - 'components/-ember-popper-legacy.hbs' - ], - getDestinationPath: replaceLegacyPath - }); - } - - return this._super.treeForAddonTemplates.call(this, tree); - }, - - treeForAddon(tree) { - const _emberChecker = this._emberChecker; - - if (_emberChecker.gte('2.10.0')) { - tree = new Funnel(tree, { - exclude: [ - 'components/-ember-popper-legacy.js' - ] - }); - } else { - tree = new Funnel(tree, { - exclude: [ - 'components/ember-popper.js' - ], - getDestinationPath: replaceLegacyPath - }); - } - - return this._super.treeForAddon.call(this, tree); } -}; -function replaceLegacyPath(relativePath) { - return relativePath.replace(/-ember-popper-legacy(-1.11)?/g, 'ember-popper'); -} +}; diff --git a/package.json b/package.json index ce23324..f7403d4 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,12 @@ "ember-cli-babel": "^6.10.0", "ember-cli-htmlbars": "^2.0.3", "ember-cli-node-assets": "^0.2.2", - "ember-cli-version-checker": "^2.1.0", "ember-compatibility-helpers": "^0.1.3", "ember-decorators": "^1.3.2", + "ember-hash-helper-polyfill": "^0.2.1", + "ember-in-element-polyfill": "^0.1.2", "ember-legacy-class-transform": "^0.1.4", + "ember-maybe-in-element": "^0.1.3", "ember-raf-scheduler": "^0.1.0", "fastboot-transform": "^0.1.0", "popper.js": "^1.12.9" @@ -53,7 +55,6 @@ "ember-cli-uglify": "^2.0.0", "ember-disable-prototype-extensions": "^1.1.3", "ember-export-application-global": "^2.0.0", - "ember-hash-helper-polyfill": "^0.2.0", "ember-load-initializers": "^1.0.0", "ember-native-dom-event-dispatcher": "^0.6.3", "ember-native-dom-helpers": "^0.5.8", diff --git a/yarn.lock b/yarn.lock index 9344d75..47dc246 100644 --- a/yarn.lock +++ b/yarn.lock @@ -610,6 +610,12 @@ babel-plugin-ember-modules-api-polyfill@^2.0.1: dependencies: ember-rfc176-data "^0.2.7" +babel-plugin-ember-modules-api-polyfill@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-2.3.0.tgz#0c01f359658cfb9c797f705af6b09f6220205ae0" + dependencies: + ember-rfc176-data "^0.3.0" + babel-plugin-eval@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-eval/-/babel-plugin-eval-1.0.1.tgz#a2faed25ce6be69ade4bfec263f70169195950da" @@ -1119,6 +1125,10 @@ bower-endpoint-parser@0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/bower-endpoint-parser/-/bower-endpoint-parser-0.2.2.tgz#00b565adbfab6f2d35addde977e97962acbcb3f6" +bower@^1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/bower/-/bower-1.8.2.tgz#adf53529c8d4af02ef24fb8d5341c1419d33e2f7" + brace-expansion@^1.0.0, brace-expansion@^1.1.7: version "1.1.8" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" @@ -1305,7 +1315,7 @@ broccoli-funnel-reducer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/broccoli-funnel-reducer/-/broccoli-funnel-reducer-1.0.0.tgz#11365b2a785aec9b17972a36df87eef24c5cc0ea" -broccoli-funnel@^1.0.0, broccoli-funnel@^1.0.1, broccoli-funnel@^1.1.0, broccoli-funnel@^1.2.0: +broccoli-funnel@^1.0.0, broccoli-funnel@^1.0.1, broccoli-funnel@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-1.2.0.tgz#cddc3afc5ff1685a8023488fff74ce6fb5a51296" dependencies: @@ -2068,7 +2078,7 @@ ember-cli-babel@^5.1.6: ember-cli-version-checker "^1.0.2" resolve "^1.1.2" -ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.3.0, ember-cli-babel@^6.4.1, ember-cli-babel@^6.6.0, ember-cli-babel@^6.7.2, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2: +ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.3.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.7.2, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2: version "6.8.2" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.8.2.tgz#eac2785964f4743f4c815cd53c6288f00cc087d7" dependencies: @@ -2103,6 +2113,24 @@ ember-cli-babel@^6.10.0: ember-cli-version-checker "^2.1.0" semver "^5.4.1" +ember-cli-babel@^6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.11.0.tgz#79cb184bac3c05bfe181ddc306bac100ab1f9493" + dependencies: + amd-name-resolver "0.0.7" + babel-plugin-debug-macros "^0.1.11" + babel-plugin-ember-modules-api-polyfill "^2.3.0" + babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-polyfill "^6.16.0" + babel-preset-env "^1.5.1" + broccoli-babel-transpiler "^6.1.2" + broccoli-debug "^0.6.2" + broccoli-funnel "^1.0.0" + broccoli-source "^1.1.0" + clone "^2.0.0" + ember-cli-version-checker "^2.1.0" + semver "^5.4.1" + ember-cli-broccoli-sane-watcher@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/ember-cli-broccoli-sane-watcher/-/ember-cli-broccoli-sane-watcher-2.0.4.tgz#f43f42f75b7509c212fb926cd9aea86ae19264c6" @@ -2168,7 +2196,7 @@ ember-cli-htmlbars-inline-precompile@^1.0.2: heimdalljs-logger "^0.1.7" silent-error "^1.1.0" -ember-cli-htmlbars@^2.0.3: +ember-cli-htmlbars@^2.0.1, ember-cli-htmlbars@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/ember-cli-htmlbars/-/ember-cli-htmlbars-2.0.3.tgz#e116e1500dba12f29c94b05b9ec90f52cb8bb042" dependencies: @@ -2256,16 +2284,6 @@ ember-cli-qunit@^4.1.1: ember-cli-babel "^6.8.1" ember-qunit "^3.1.0" -ember-cli-shims@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ember-cli-shims/-/ember-cli-shims-1.2.0.tgz#0f53aff0aab80b5f29da3a9731bac56169dd941f" - dependencies: - broccoli-file-creator "^1.1.1" - broccoli-merge-trees "^2.0.0" - ember-cli-version-checker "^2.0.0" - ember-rfc176-data "^0.3.1" - silent-error "^1.0.1" - ember-cli-sri@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ember-cli-sri/-/ember-cli-sri-2.1.1.tgz#971620934a4b9183cf7923cc03e178b83aa907fd" @@ -2301,7 +2319,7 @@ ember-cli-valid-component-name@^1.0.0: dependencies: silent-error "^1.0.0" -ember-cli-version-checker@^1.0.2, ember-cli-version-checker@^1.1.6, ember-cli-version-checker@^1.1.7, ember-cli-version-checker@^1.2.0: +ember-cli-version-checker@^1.0.2, ember-cli-version-checker@^1.1.6, ember-cli-version-checker@^1.1.7: version "1.3.1" resolved "https://registry.yarnpkg.com/ember-cli-version-checker/-/ember-cli-version-checker-1.3.1.tgz#0bc2d134c830142da64bf9627a0eded10b61ae72" dependencies: @@ -2462,12 +2480,21 @@ ember-get-config@^0.2.3: broccoli-file-creator "^1.1.1" ember-cli-babel "^6.3.0" -ember-hash-helper-polyfill@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/ember-hash-helper-polyfill/-/ember-hash-helper-polyfill-0.2.0.tgz#0913a06ad59147f345dff0edda04b112deba0f7e" +ember-hash-helper-polyfill@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ember-hash-helper-polyfill/-/ember-hash-helper-polyfill-0.2.1.tgz#73b074d8e2f7183d2e68c3df77e951097afa907c" dependencies: ember-cli-babel "^6.8.2" - ember-cli-version-checker "^1.2.0" + ember-cli-version-checker "^2.1.0" + +ember-in-element-polyfill@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ember-in-element-polyfill/-/ember-in-element-polyfill-0.1.2.tgz#6a73423869e0f330c40a48d75a71d1c36161cbd6" + dependencies: + debug "^3.1.0" + ember-cli-babel "^6.6.0" + ember-cli-version-checker "^2.1.0" + ember-wormhole "^0.5.4" ember-legacy-class-transform@^0.1.4: version "0.1.4" @@ -2492,11 +2519,11 @@ ember-macro-helpers@^0.16.0: ember-cli-test-info "^1.0.0" ember-weakmap "^2.0.0" -ember-native-dom-event-dispatcher@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/ember-native-dom-event-dispatcher/-/ember-native-dom-event-dispatcher-0.6.3.tgz#3b2f10dcf82f9aaa4dd211a704ac511fd8714720" +ember-maybe-in-element@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/ember-maybe-in-element/-/ember-maybe-in-element-0.1.3.tgz#1c89be49246e580c1090336ad8be31e373f71b60" dependencies: - ember-cli-babel "^6.4.1" + ember-cli-babel "^6.11.0" ember-native-dom-helpers@^0.5.8: version "0.5.8" @@ -2539,36 +2566,16 @@ ember-rfc176-data@^0.2.7: version "0.2.7" resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.2.7.tgz#bd355bc9b473e08096b518784170a23388bc973b" -ember-rfc176-data@^0.3.1: +ember-rfc176-data@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.1.tgz#6a5a4b8b82ec3af34f3010965fa96b936ca94519" -ember-router-generator@^1.0.0, ember-router-generator@^1.2.3: +ember-router-generator@^1.0.0: version "1.2.3" resolved "https://registry.yarnpkg.com/ember-router-generator/-/ember-router-generator-1.2.3.tgz#8ed2ca86ff323363120fc14278191e9e8f1315ee" dependencies: recast "^0.11.3" -ember-source@~2.17.0: - version "2.17.0" - resolved "https://registry.yarnpkg.com/ember-source/-/ember-source-2.17.0.tgz#b78871dd49bd8d642b80176df4faf7fd7d059dac" - dependencies: - broccoli-funnel "^1.2.0" - broccoli-merge-trees "^2.0.0" - ember-cli-get-component-path-option "^1.0.0" - ember-cli-is-package-missing "^1.0.0" - ember-cli-normalize-entity-name "^1.0.0" - ember-cli-path-utils "^1.0.0" - ember-cli-string-utils "^1.1.0" - ember-cli-test-info "^1.0.0" - ember-cli-valid-component-name "^1.0.0" - ember-cli-version-checker "^2.1.0" - ember-router-generator "^1.2.3" - fs-extra "^4.0.1" - inflection "^1.12.0" - jquery "^3.2.1" - resolve "^1.3.3" - ember-try-config@^2.0.1: version "2.1.0" resolved "https://registry.yarnpkg.com/ember-try-config/-/ember-try-config-2.1.0.tgz#e0e156229a542346a58ee6f6ad605104c98edfe0" @@ -2602,6 +2609,13 @@ ember-weakmap@^2.0.0: dependencies: ember-cli-babel "^5.1.6" +ember-wormhole@^0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/ember-wormhole/-/ember-wormhole-0.5.4.tgz#968e80f093494f4aed266e750afa63919c61383d" + dependencies: + ember-cli-babel "^6.10.0" + ember-cli-htmlbars "^2.0.1" + encodeurl@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" @@ -3130,14 +3144,6 @@ fs-extra@^4.0.0: jsonfile "^3.0.0" universalify "^0.1.0" -fs-extra@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.2.tgz#f91704c53d1b461f893452b0c307d9997647ab6b" - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - fs-readdir-recursive@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-0.1.2.tgz#315b4fb8c1ca5b8c47defef319d073dad3568059" @@ -3481,7 +3487,7 @@ indexof@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" -inflection@^1.12.0, inflection@^1.7.0, inflection@^1.7.1: +inflection@^1.7.0, inflection@^1.7.1: version "1.12.0" resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416" @@ -3728,10 +3734,6 @@ jquery-deferred@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/jquery-deferred/-/jquery-deferred-0.3.1.tgz#596eca1caaff54f61b110962b23cafea74c35355" -jquery@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787" - js-reporters@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/js-reporters/-/js-reporters-1.2.0.tgz#7cf2cb698196684790350d0c4ca07f4aed9ec17e" @@ -3817,12 +3819,6 @@ jsonfile@^3.0.0: optionalDependencies: graceful-fs "^4.1.6" -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - optionalDependencies: - graceful-fs "^4.1.6" - jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"