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

bugfix(transform): Disable handlebars transform pre-Ember-1.13 #150

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ module.exports = {
let host = this._findHost();
this._assignOptions(host);

// we can't use the setupPreprocessorRegistry() hook as it is called to
// early and we do not have reliable access to `app.tests` there yet
this._setupPreprocessorRegistry(app.registry);
let emberChecker = new VersionChecker(app).forEmber();

if (emberChecker.isAbove('1.13.0')) {
// we can't use the setupPreprocessorRegistry() hook as it is called to
// early and we do not have reliable access to `app.tests` there yet
this._setupPreprocessorRegistry(app.registry);
}

// add the StripDataTestPropertiesPlugin to the list of plugins used by
// the `ember-cli-babel` addon
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ember-cli-inject-live-reload": "^1.6.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-compatibility-helpers": "^0.1.2",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.3.0",
Expand All @@ -55,7 +56,7 @@
"ember-addon": {
"configPath": "tests/dummy/config",
"versionCompatibility": {
"ember": ">=1.13"
"ember": ">=1.11"
}
},
"greenkeeper": {
Expand Down
34 changes: 19 additions & 15 deletions tests/acceptance/bind-data-test-attributes-in-components-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';

import config from 'dummy/config/environment';

import { GTE_EMBER_1_13 } from 'ember-compatibility-helpers';

if (!config.stripTestSelectors) {

/*
Expand Down Expand Up @@ -47,23 +49,25 @@ if (!config.stripTestSelectors) {
assert.equal(find('.test6').find('div[data-non-test]').length, 0, 'data-non-test does not exists');
});

test('it binds data-test-* attributes with boolean values on components', function(assert) {
assert.equal(find('.test7').find('div[data-test-with-boolean-value]').length, 1, 'data-test-with-boolean-value exists');
});
if (GTE_EMBER_1_13) {
test('it binds data-test-* attributes with boolean values on components', function(assert) {
assert.equal(find('.test7').find('div[data-test-with-boolean-value]').length, 1, 'data-test-with-boolean-value exists');
});

test('it binds data-test-* attributes without values on components', function(assert) {
assert.equal(find('.test8').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});
test('it binds data-test-* attributes without values on components', function(assert) {
assert.equal(find('.test8').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});

test('it binds data-test-* attributes without values on block components', function(assert) {
assert.equal(find('.test9').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});
test('it binds data-test-* attributes without values on block components', function(assert) {
assert.equal(find('.test9').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});

test('it leaves data-test attribute without value untouched on components', function(assert) {
assert.equal(find('.test10').find('div[data-test]').length, 0, 'data-test does not exists');
});
test('it leaves data-test attribute without value untouched on components', function(assert) {
assert.equal(find('.test10').find('div[data-test]').length, 0, 'data-test does not exists');
});

test('it transforms data-test params to hash pairs on components', function(assert) {
assert.equal(find('.test11').find('div[data-test-something]').length, 1, 'data-test-something exists');
});
test('it transforms data-test params to hash pairs on components', function(assert) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be the only test that fails for Ember < 1.13?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @pzuraq might be right. Using the versionCompat feature of ember-try and ember-source together has some issues at the moment, and we might only be testing against ember-source in all scenarios 😱

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, so "best" solution for now might be to remove this one test for now (as well as investigating the bug and fixing it in ember-try)?

Copy link
Contributor Author

@pzuraq pzuraq Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole block of tests I commented out will fail for Ember <1.13 because positional params didn’t exist yet. They passed before because the transform was working (due to incorrect Ember version being detected) and changing the positional params into named params.

assert.equal(find('.test11').find('div[data-test-something]').length, 1, 'data-test-something exists');
});
}
}
8 changes: 8 additions & 0 deletions tests/dummy/app/controllers/bind-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Ember from 'ember';
import { GTE_EMBER_1_13 } from 'ember-compatibility-helpers';

const { Controller } = Ember;

export default Controller.extend({
shouldRenderParamTests: GTE_EMBER_1_13
});
10 changes: 6 additions & 4 deletions tests/dummy/app/templates/bind-test.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

<div class="test7">{{data-test-component data-test-with-boolean-value=true}}</div>

<div class="test8">{{data-test-component data-test-without-value}}</div>
{{#if shouldRenderParamTests}}
<div class="test8">{{data-test-component data-test-without-value}}</div>

<div class="test9">{{#data-test-component data-test-without-value}}foo{{/data-test-component}}</div>
<div class="test9">{{#data-test-component data-test-without-value}}foo{{/data-test-component}}</div>

<div class="test10">{{data-test-component data-test}}</div>
<div class="test10">{{data-test-component data-test}}</div>

<div class="test11">{{data-test-component data-test-something some-prop="prop"}}</div>
<div class="test11">{{data-test-component data-test-something some-prop="prop"}}</div>
{{/if}}
Loading