Skip to content

Commit

Permalink
Merge pull request #117 from salsify/fix-splattributes
Browse files Browse the repository at this point in the history
Fix #116
  • Loading branch information
dfreeman authored Sep 28, 2018
2 parents aa960ae + 5b057f6 commit 9ad580e
Show file tree
Hide file tree
Showing 6 changed files with 1,501 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/htmlbars-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = class ClassTransformPlugin {

utils.pushAll(parts, this.localToPath(localClassAttr.value));
this.divide(parts, this.isGlimmer ? 'text' : 'string');
node.attributes.push(this.builders.attr('class', this.builders.concat(parts)));
node.attributes.unshift(this.builders.attr('class', this.builders.concat(parts)));
}

localToPath(node) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-test-loader": "^2.2.0",
"ember-cli-uglify": "^2.1.0",
"ember-compatibility-helpers": "^1.0.2",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.local-inner {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{! template-lint-disable }}
{{! (seems like the alignment rule doesn't work right with splattributes) }}

<div
class="global-inner"
local-class="local-inner"
data-test-element
...attributes
>
</div>
24 changes: 24 additions & 0 deletions tests/integration/splattributes-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import setupStyles from '../helpers/render-with-styles';
import { gte } from 'ember-compatibility-helpers';
import styles from 'dummy/components/component-with-splattributes/styles';

if (gte('3.4.0')) {
module('Integration | Components with splattributes', function(hooks) {
setupRenderingTest(hooks);

test('inner and outer local and global classes are all present', async function(assert) {
const hbs = setupStyles({
'local-outer': '--local-outer'
});

await render(hbs`<ComponentWithSplattributes local-class="local-outer" class="global-outer" />`);
assert.dom('[data-test-element]').hasClass('global-outer');
assert.dom('[data-test-element]').hasClass('--local-outer');
assert.dom('[data-test-element]').hasClass('global-inner');
assert.dom('[data-test-element]').hasClass(styles['local-inner']);
});
});
}
Loading

0 comments on commit 9ad580e

Please sign in to comment.