diff --git a/.travis.yml b/.travis.yml index 49cae049..26ad7cda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: node_js node_js: - - "4" + - "6" sudo: false dist: trusty diff --git a/addon/-debug/helpers.js b/addon/-debug/helpers.js index 4eb10c3a..0a22d103 100644 --- a/addon/-debug/helpers.js +++ b/addon/-debug/helpers.js @@ -1,5 +1,4 @@ import Ember from 'ember'; -const { Logger } = Ember; export function assert(msg, conditional) { if (!conditional) { @@ -8,7 +7,7 @@ export function assert(msg, conditional) { } export function debug() { - Logger.debug(...arguments); + Ember.Logger.debug(...arguments); } export function debugOnError(msg, conditional) { diff --git a/index.js b/index.js index 2f7214b3..1a1d80d0 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,10 @@ /* eslint-env node */ 'use strict'; -const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck'); const FilterImports = require('babel-plugin-filter-imports'); -const RemoveImports = require('./lib/babel-plugin-remove-imports'); const Funnel = require('broccoli-funnel'); +const RemoveImports = require('./lib/babel-plugin-remove-imports'); +const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck'); module.exports = { name: 'ember-attacher', @@ -22,24 +22,24 @@ module.exports = { return; } - if (/production/.test(env) || /test/.test(env)) { - var strippedImports = { - 'ember-attacher/-debug/helpers': [ - 'assert', - 'debug', - 'debugOnError', - 'stripInProduction' - ] - }; - + if (/production/.test(env)) { // In some versions of Ember, this.options is undefined during tests this.options = this.options || {}; // Make sure the babel options are accessible - let babelOptions = this.options.babel = this.options.babel || {}; + const babelOptions = this.options.babel = this.options.babel || {}; + babelOptions.plugins = babelOptions.plugins || []; babelOptions.postTransformPlugins = babelOptions.postTransformPlugins || []; + const strippedImports = { + 'ember-attacher/-debug/helpers': [ + 'assert', + 'debug', + 'debugOnError', + 'stripInProduction' + ] + }; babelOptions.plugins.push([FilterImports, strippedImports]); babelOptions.plugins.push([RemoveImports, 'ember-attacher/-debug/helpers']); babelOptions.postTransformPlugins.push(StripClassCallCheck); @@ -48,13 +48,11 @@ module.exports = { this._hasSetupBabelOptions = true; }, - treeForAddon: function() { - var tree = this._super.treeForAddon.apply(this, arguments); - - if (/production/.test(this._env) || /test/.test(this._env)) { + treeForAddon: function(tree) { + if (/production/.test(this._env)) { tree = new Funnel(tree, { exclude: [ /-debug/ ] }); } - return tree; + return this._super.treeForAddon.call(this, tree); } }; diff --git a/package.json b/package.json index eb9df89a..b90d5a40 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,10 @@ "deploy": "ember github-pages:commit --message \"Deploy gh-pages from commit $(git rev-parse HEAD)\"; git push; git checkout -" }, "dependencies": { + "babel-eslint": "^7.2.3", + "babel-plugin-filter-imports": "^0.3.1", + "babel6-plugin-strip-class-callcheck": "^6.0.0", + "broccoli-funnel": "^1.0.7", "ember-cli-babel": "^6.8.1", "ember-cli-htmlbars": "^2.0.2", "ember-cli-sass": "^7.0.0", diff --git a/tests/dummy/app/templates/components/attachment-example.hbs b/tests/dummy/app/templates/components/attachment-example.hbs index f6e22a00..cd2ba76e 100644 --- a/tests/dummy/app/templates/components/attachment-example.hbs +++ b/tests/dummy/app/templates/components/attachment-example.hbs @@ -83,7 +83,7 @@   \{{ #ember-attacher - {{#ember-attacher popperClass="ember-attacher-popper tooltip"}} + {{#ember-attacher popperClass="ember-attacher-popper ember-attacher-tooltip"}} {{#if isConfiguringTooltip}} The "Tooltip in a parent" ember-attacher is initially set to the default settings. Twiddle some knobs to see what ember-attacher can do! diff --git a/tests/integration/components/ember-attacher-test.js b/tests/integration/components/ember-attacher-test.js index 9bd2e96b..5e2cf1b5 100644 --- a/tests/integration/components/ember-attacher-test.js +++ b/tests/integration/components/ember-attacher-test.js @@ -1,5 +1,5 @@ import { click, find } from 'ember-native-dom-helpers'; -import { moduleForComponent, test, todo } from 'ember-qunit'; +import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; moduleForComponent('ember-attacher', 'Integration | Component | ember attacher', { @@ -41,7 +41,7 @@ test('it renders', function(assert) { assert.equal(innerHTML.indexOf('popper text'), 0); }); -todo('nested attachers open and close as expected', async function(assert) { +test('nested attachers open and close as expected', async function(assert) { assert.expect(6); this.on('openParentPopover', () => { @@ -63,7 +63,6 @@ todo('nested attachers open and close as expected', async function(assert) { showOn: 'none' }); - //TODO: figure out how to fire actions from inside components this.render(hbs`