-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated to maintain roughly the same api, but remove monkeypatches #123
Changes from 10 commits
96948a6
770538f
27c9ff0
6f16ec8
da53416
2d19201
a48f9a2
ce2b691
ce35f16
e88ea12
de54b2d
0f79553
82508ce
e5836fa
82591bc
586b8e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
bower_components/ | ||
tests/ | ||
tmp/ | ||
dist/ | ||
|
||
/bower_components | ||
/config/ember-try.js | ||
/dist | ||
/tests | ||
/tmp | ||
**/.gitkeep | ||
.bowerrc | ||
.editorconfig | ||
.ember-cli | ||
.gitignore | ||
.jshintrc | ||
.watchmanconfig | ||
.travis.yml | ||
.npmignore | ||
**/.gitkeep | ||
bower.json | ||
Brocfile.js | ||
testem.json | ||
ember-cli-build.js | ||
testem.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Ember from 'ember'; | ||
import podNames from 'ember-component-css/pod-names'; | ||
|
||
const { | ||
Component, | ||
ComponentLookup, | ||
} = Ember; | ||
|
||
export function initialize() { | ||
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
if (podNames[name] && !owner.application.hasRegistration('component:' + name)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Ember 2.3 and higher, owner.application should not be used. You should use owner.hasRegistration and owner.register. To enable usage of the same API across older Ember versions you can use the ember-getowner-polyfill. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, wouldn't it be easier to call super and check if the return value is undefined instead of manually checking registration like this? Something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had tried this it wasn't working for me. I think cause _lookupFactory does more then just return the constructor. I would have to call super again at the end, which calling it twice felt weird. |
||
owner.application.register('component:' + name, Component); | ||
} | ||
return this._super(...arguments); | ||
} | ||
}); | ||
|
||
Component.reopen({ | ||
init() { | ||
this._super(...arguments); | ||
if (this.get('tagName') !== '' && this._debugContainerKey) { | ||
const name = this._debugContainerKey.replace('component:', ''); | ||
if (podNames[name]) { | ||
this.classNames.push(podNames[name]); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
export default { | ||
name: 'component-styles', | ||
initialize | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, initialize } from 'ember-component-css/initializers/component-styles'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
{ | ||
"name": "ember-component-css", | ||
"dependencies": { | ||
"ember": "1.13.12", | ||
"ember-cli-shims": "0.0.6", | ||
"ember-cli-test-loader": "0.2.1", | ||
"ember-data": "1.13.15", | ||
"ember-load-initializers": "0.1.7", | ||
"ember-qunit": "0.4.16", | ||
"ember-qunit-notifications": "0.1.0", | ||
"ember-resolver": "~0.1.20", | ||
"jquery": "1.11.3", | ||
"loader.js": "ember-cli/loader.js#3.4.0", | ||
"qunit": "~1.20.0" | ||
"ember": "~2.4.1", | ||
"ember-cli-shims": "0.1.0", | ||
"ember-cli-test-loader": "0.2.2", | ||
"ember-qunit-notifications": "0.1.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
/*jshint node:true*/ | ||
/* global require, module */ | ||
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); | ||
module.exports = function(defaults) { | ||
var app = new EmberAddon(defaults, { | ||
// Add options here | ||
}); | ||
/* | ||
This build file specifes the options for the dummy test app of this | ||
addon, located in `/tests/dummy` | ||
This build file does *not* influence how the addon or the app using it | ||
behave. You most likely want to be modifying `./index.js` or app's build file | ||
*/ | ||
return app.toTree(); | ||
}; | ||
/*jshint node:true*/ | ||
/* global require, module */ | ||
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); | ||
|
||
module.exports = function(defaults) { | ||
var app = new EmberAddon(defaults, { | ||
// Add options here | ||
}); | ||
|
||
/* | ||
This build file specifies the options for the dummy test app of this | ||
addon, located in `/tests/dummy` | ||
This build file does *not* influence how the addon or the app using it | ||
behave. You most likely want to be modifying `./index.js` or app's build file | ||
*/ | ||
|
||
return app.toTree(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This work should not be done inside the initialize function (if it is it will be reran once for every test. It should be done in the root of the module so that it is only done once when the module is evaluated (and before the application itself is created).