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..e9f53e6 100644 --- a/addon/components/ember-popper.js +++ b/addon/components/ember-popper.js @@ -1,10 +1,169 @@ -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 ================== + didInsertElement() { + this._initialParentNode = this._parentFinder.parentNode; + + super.didInsertElement(...arguments); + } + + didRender() { + this._updatePopper(); + } + init() { this.id = this.id || `${guidFor(this)}-popper`; this._parentFinder = self.document ? self.document.createTextNode('') : ''; @@ -12,9 +171,188 @@ export default class EmberPopper extends EmberPopperBase { super.init(...arguments); } - didInsertElement() { - this._initialParentNode = this._parentFinder.parentNode; + willDestroyElement() { + super.willDestroyElement(...arguments); - super.didInsertElement(...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..1dae6d8 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,11 @@ "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 +54,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/testem.js b/testem.js index 63d1edf..c774723 100644 --- a/testem.js +++ b/testem.js @@ -15,7 +15,8 @@ module.exports = { '--disable-gpu', '--headless', '--remote-debugging-port=0', - '--window-size=1440,900' + '--window-size=1440,900', + '--no-sandbox' ] } } diff --git a/tests/integration/components/ember-popper/action-test.js b/tests/integration/components/ember-popper/action-test.js index e3b8c7b..d8fc634 100644 --- a/tests/integration/components/ember-popper/action-test.js +++ b/tests/integration/components/ember-popper/action-test.js @@ -2,51 +2,48 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import { triggerEvent } from 'ember-native-dom-helpers'; import wait from 'ember-test-helpers/wait'; -import hasEmberVersion from 'ember-test-helpers/has-ember-version'; -if (hasEmberVersion(1, 13)) { - moduleForComponent('ember-popper', 'Integration | Component | actions', { - integration: true - }); +moduleForComponent('ember-popper', 'Integration | Component | actions', { + integration: true +}); - test('it calls onCreate', function(assert) { - assert.expect(2); - let called = 0; - const action = (data) => { - called++; - assert.ok(data && data.instance, 'onCreate action is called with dataObject'); - }; - this.on('create', action); - this.render(hbs` +test('it calls onCreate', function(assert) { + assert.expect(2); + let called = 0; + const action = (data) => { + called++; + assert.ok(data && data.instance, 'onCreate action is called with dataObject'); + }; + this.on('create', action); + this.render(hbs` {{#ember-popper onCreate=(action "create")}} template block text {{/ember-popper}} `); - return wait() - .then(() => assert.equal(called, 1, 'onCreate action has been called')); - }); + return wait() + .then(() => assert.equal(called, 1, 'onCreate action has been called')); +}); - test('it calls onUpdate', function(assert) { - assert.expect(2); - let called = 0; - const action = (data) => { - called++; - assert.ok(data && data.instance, 'onUpdate action is called with dataObject'); - }; - this.on('update', action); - this.render(hbs` +test('it calls onUpdate', function(assert) { + assert.expect(2); + let called = 0; + const action = (data) => { + called++; + assert.ok(data && data.instance, 'onUpdate action is called with dataObject'); + }; + this.on('update', action); + this.render(hbs` {{#ember-popper onUpdate=(action "update")}} template block text {{/ember-popper}} `); - return wait() - .then(() => triggerEvent(document.querySelector('body'), 'scroll')) - .then(wait) - .then(() => { - assert.equal(called, 1, 'onUpdate action has been called after event'); - return wait(); - }); - }); -} + return wait() + .then(() => triggerEvent(document.querySelector('body'), 'scroll')) + .then(() => wait()) + .then(() => { + assert.equal(called, 1, 'onUpdate action has been called after event'); + return wait(); + }); +}); diff --git a/yarn.lock b/yarn.lock index 9344d75..e93076d 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" @@ -2068,7 +2074,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 +2109,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 +2192,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: @@ -2301,7 +2325,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: @@ -2426,14 +2450,6 @@ ember-compatibility-helpers@^0.1.1: ember-cli-version-checker "^2.0.0" semver "^5.4.1" -ember-compatibility-helpers@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-0.1.3.tgz#039a57e9f1a401efda0023c1e3650bd01cfd7087" - dependencies: - babel-plugin-debug-macros "^0.1.11" - ember-cli-version-checker "^2.0.0" - semver "^5.4.1" - ember-decorators@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/ember-decorators/-/ember-decorators-1.3.2.tgz#494482e50599010ced597da91d9bc9fe7838f46b" @@ -2462,12 +2478,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 +2517,18 @@ ember-macro-helpers@^0.16.0: ember-cli-test-info "^1.0.0" ember-weakmap "^2.0.0" +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.11.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" + version "0.6.4" + resolved "https://registry.yarnpkg.com/ember-native-dom-event-dispatcher/-/ember-native-dom-event-dispatcher-0.6.4.tgz#ba03d512a72d159a376b27593b497ba08fe14a8a" dependencies: - ember-cli-babel "^6.4.1" + ember-cli-babel "^6.11.0" + ember-cli-version-checker "^2.1.0" ember-native-dom-helpers@^0.5.8: version "0.5.8" @@ -2539,7 +2571,7 @@ 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, ember-rfc176-data@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.1.tgz#6a5a4b8b82ec3af34f3010965fa96b936ca94519" @@ -2602,6 +2634,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" @@ -3131,8 +3170,8 @@ fs-extra@^4.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" + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" dependencies: graceful-fs "^4.1.2" jsonfile "^4.0.0"