Skip to content
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

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
96948a6
Updated to maintain roughly the same api,
webark Mar 9, 2016
770538f
using plain init and calling super for better preformance per @stefan…
webark Mar 9, 2016
27c9ff0
using a persistant filter so that the output will be cached accross r…
webark Mar 9, 2016
6f16ec8
using .get for the tagname since it is a member of a ember object, an…
webark Mar 10, 2016
da53416
updated to use postcss and simpliy modifying the css rules for the fi…
webark Mar 10, 2016
2d19201
added plugin to remove empty files. Am somewhat concerned that this i…
webark Mar 10, 2016
a48f9a2
brings in line with the expected output of ember init
webark Mar 18, 2016
ce2b691
moving actual dependecies to from dev to dependencies to ensure that …
webark Mar 18, 2016
ce35f16
switched generating the pod name json file to use fs-tree-diff and pe…
webark Mar 18, 2016
e88ea12
switched to using glob syntax as per @stefanpenner suggestion
webark Mar 19, 2016
de54b2d
moved the componentlookup and compont repoens out of the initialize m…
webark Mar 21, 2016
0f79553
using the updated api of calling the methods on the owner rather then…
webark Mar 21, 2016
82508ce
switched to apply and passing in all arguments per @rjwblue suggestion
webark Mar 21, 2016
e5836fa
since the 'concatination' of the file wasn't preserving the source ma…
webark Mar 21, 2016
82591bc
moved to standard object function declaration to support lesser versi…
webark Mar 21, 2016
586b8e9
moving more function declarations to support lesser versions of node …
webark Mar 21, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .npmignore
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cache:

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-1-13
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015
Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
36 changes: 36 additions & 0 deletions addon/initializers/component-styles.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() {
Copy link
Collaborator

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).


ComponentLookup.reopen({
componentFor(name, owner) {
if (podNames[name] && !owner.application.hasRegistration('component:' + name)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The 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:

let FoundComponent = this._super(...arguments);
If (podNames[name] && !FoundComponent) { 
  FoundComponent = Component;
  owner.register('component:' + name, FoundComponent);
}

return FoundComponent;

Copy link
Owner Author

Choose a reason for hiding this comment

The 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
};
1 change: 1 addition & 0 deletions addon/pod-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Empty file removed app/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions app/initializers/component-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, initialize } from 'ember-component-css/initializers/component-styles';
15 changes: 4 additions & 11 deletions bower.json
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"
}
}
51 changes: 35 additions & 16 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,52 @@ module.exports = {
scenarios: [
{
name: 'default',
dependencies: { }
bower: {
dependencies: { }
}
},
{
name: 'ember-1-13',
bower: {
dependencies: {
'ember': '~1.13.0'
},
resolutions: {
'ember': '~1.13.0'
}
}
},
{
name: 'ember-release',
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
bower: {
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
}
},
{
name: 'ember-beta',
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
bower: {
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
}
},
{
name: 'ember-canary',
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
bower: {
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
}
}
]
Expand Down
36 changes: 18 additions & 18 deletions ember-cli-build.js
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();
};
Loading