-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module imports): moved functionality that belonged to just the ad…
…don, over to the addon. fix #259
- Loading branch information
Showing
5 changed files
with
99 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Ember from "ember"; | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { getOwner } from '@ember/application'; | ||
|
||
import podNames from 'ember-component-css/pod-names'; | ||
|
||
const { | ||
ComponentLookup, | ||
} = Ember; | ||
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
owner = owner.hasRegistration ? owner : getOwner(this); | ||
|
||
if (podNames[name] && !owner.hasRegistration(`component:${name}`)) { | ||
owner.register(`component:${name}`, Component); | ||
} | ||
return this._super(...arguments); | ||
}, | ||
}); | ||
|
||
Component.reopen({ | ||
_componentIdentifier: computed({ | ||
get() { | ||
return (this._debugContainerKey || '').replace('component:', ''); | ||
} | ||
}), | ||
|
||
_shouldAddNamespacedClassName: computed({ | ||
get() { | ||
return this.get('tagName') !== '' && this.get('styleNamespace'); | ||
} | ||
}), | ||
|
||
styleNamespace: computed({ | ||
get() { | ||
return podNames[this.get('_componentIdentifier')] || ''; | ||
} | ||
}), | ||
|
||
// componentCssClassName: deprecatingAlias('styleNamespace', { | ||
// id: 'ember-component-css.deprecate-componentCssClassName', | ||
// until: '0.7.0', | ||
// }), | ||
|
||
componentCssClassName: alias('styleNamespace'), | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
if (this.get('_shouldAddNamespacedClassName')) { | ||
this.classNames = this.classNames.concat(this.get('styleNamespace')); | ||
} | ||
}, | ||
}); | ||
|
||
export function initialize() {} | ||
|
||
export default { | ||
initialize | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Router from '@ember/routing/router'; | ||
import { getOwner } from '@ember/application'; | ||
|
||
import podNames from 'ember-component-css/pod-names'; | ||
|
||
Router.reopen({ | ||
didTransition(routes) { | ||
this._super(...arguments); | ||
|
||
const classes = []; | ||
for (let i = 0; i < routes.length; i++) { | ||
let route = routes[i]; | ||
let currentPath = route.name.replace(/\./g, '/'); | ||
|
||
if (podNames[currentPath]) { | ||
getOwner(this).lookup(`controller:${route.name}`).set('styleNamespace', podNames[currentPath]); | ||
classes.push(podNames[currentPath]); | ||
} | ||
} | ||
|
||
getOwner(this).lookup('controller:application').set('routeStyleNamespaceClassSet', classes.join(' ')); | ||
} | ||
}); | ||
|
||
export function initialize() {} | ||
|
||
export default { | ||
initialize | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
import Mixin from '@ember/object/mixin'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Mixin.create({ | ||
_componentIdentifier: computed({ | ||
get() { | ||
return (this._debugContainerKey || '').replace('component:', ''); | ||
} | ||
}), | ||
|
||
_shouldAddNamespacedClassName: computed({ | ||
get() { | ||
return this.get('tagName') !== '' && this.get('styleNamespace'); | ||
} | ||
}), | ||
}); | ||
export default Mixin.create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,8 @@ | ||
import Ember from "ember"; | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { getOwner } from '@ember/application'; | ||
export { default, initialize } from 'ember-component-css/initializers/component-styles'; | ||
|
||
import podNames from 'ember-component-css/pod-names'; | ||
import StyleNamespacingExtras from '../mixins/style-namespacing-extras'; | ||
|
||
const { | ||
ComponentLookup, | ||
} = Ember; | ||
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
owner = owner.hasRegistration ? owner : getOwner(this); | ||
|
||
if (podNames[name] && !owner.hasRegistration(`component:${name}`)) { | ||
owner.register(`component:${name}`, Component); | ||
} | ||
return this._super(...arguments); | ||
} | ||
}); | ||
|
||
Component.reopen(StyleNamespacingExtras, { | ||
styleNamespace: computed({ | ||
get() { | ||
return podNames[this.get('_componentIdentifier')] || ''; | ||
} | ||
}), | ||
import Ember from 'ember'; | ||
|
||
// componentCssClassName: deprecatingAlias('styleNamespace', { | ||
// id: 'ember-component-css.deprecate-componentCssClassName', | ||
// until: '0.7.0', | ||
// }), | ||
|
||
componentCssClassName: alias('styleNamespace'), | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
if (this.get('_shouldAddNamespacedClassName')) { | ||
this.classNames = this.classNames.concat(this.get('styleNamespace')); | ||
} | ||
} | ||
}); | ||
|
||
export function initialize() {} | ||
import StyleNamespacingExtras from '../mixins/style-namespacing-extras'; | ||
|
||
export default { | ||
name: 'component-styles', | ||
initialize | ||
}; | ||
// eslint-disable-next-line ember/new-module-imports | ||
Ember.Component.reopen(StyleNamespacingExtras); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1 @@ | ||
import Router from '@ember/routing/router'; | ||
import { getOwner } from '@ember/application'; | ||
import podNames from 'ember-component-css/pod-names'; | ||
|
||
Router.reopen({ | ||
didTransition(routes) { | ||
this._super(...arguments); | ||
|
||
const classes = []; | ||
for (let i = 0; i < routes.length; i++) { | ||
let route = routes[i]; | ||
let currentPath = route.name.replace(/\./g, '/'); | ||
|
||
if (podNames[currentPath]) { | ||
getOwner(this).lookup(`controller:${route.name}`).set('styleNamespace', podNames[currentPath]); | ||
classes.push(podNames[currentPath]); | ||
} | ||
} | ||
|
||
getOwner(this).lookup('controller:application').set('routeStyleNamespaceClassSet', classes.join(' ')); | ||
} | ||
}); | ||
|
||
export function initialize() {} | ||
|
||
export default { | ||
name: 'route-styles', | ||
initialize | ||
}; | ||
export { default, initialize } from 'ember-component-css/initializers/route-styles'; |