-
Notifications
You must be signed in to change notification settings - Fork 41
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
Strip "data-test-" attributes from component and helper invocations #40
Conversation
These tests are only used to check the stripping on HTML tags, not components.
This conflicts with using a `{{data-test}}` property inside a component template
@@ -0,0 +1,4 @@ | |||
<div class="attr">{{data-test-attribute}}</div> |
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 is an example of using a data-test-*
attribute in the wrong place actually. It should be stripped but should actually never appear here in the first place.
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 is only used for testing purposes to see that the data-test-attribute
is correctly stripped and nothing is rendered within the div...
}); | ||
|
||
if (config.stripTestSelectors) { | ||
|
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 needs a test that while
{{my-component data-test-attr='value'}}
becomes
<div class="ember-view" data-test-attr="value">
…
</div>
in environments that we don't strip attributes for it becomes
<div class="ember-view">
…
</div>
when data-test-*
attributes are stripped.
this.render(hbs`{{print-test-attributes data-non-test="foo"}}`); | ||
|
||
assert.equal(this.$('.non-test').text(), 'foo', 'the .non-test div is not empty'); | ||
}); |
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.
These cases actually all test edge cases. I guess that's fine but they all assume wrong usages of data-test-*
attributes.
This should also test that export default Component.extend({
'data-test-my-attr': computed(function() {
return 'whatever';
}),
… |
@@ -0,0 +1,4 @@ | |||
<div class="attr">{{data-test-attribute}}</div> |
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 is only used for testing purposes to see that the data-test-attribute
is correctly stripped and nothing is rendered within the div...
<div class="attr">{{data-test-attribute}}</div> | ||
<div class="second">{{data-test-second}}</div> | ||
<div class="non-test">{{data-non-test}}</div> | ||
<div class="data-test">{{data-test}}</div> |
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.
I think the class names in here should be named consistently to reflect the corresponding attribute. I would suggest the class name to be the same name as the attribute, so we have .data-test-attribute
, .data-test-second
, .data-non-test
and .data-test
.
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.
@pangratz good idea. done.
After a short voice conversation we've resolved a small misunderstanding about the purpose of this PR and the tests related to the tl;dr this PR is focused only on the stripping of |
This automatically removes
data-test-
prefixed attributes from component/helper invocations in templates like{{some-component data-test-name="foobar"}}
. This is roughly equal to what we've already been doing on vanilla HTML tags like<div data-test-name="foobar">
.