Add support for native class components
See original GitHub issueI’m not seeing the expected behavior when binding the data-test-*
ID within the Javascript file when using Native Classes
Taking your existing README.md
example:
export default Ember.Component({
comment: null,
'data-test-comment-id': Ember.computed.readOnly('comment.id'),
});
Now convert to use native class syntax and observe that data-test-comment-id
does not exist anymore.
Here is a very simple Ember Twiddle, inspect the DOM and you notice data-test-my-component
attribute does not exist
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Functional vs Class Components in React Native
In React Native, there are two main types of components that make up an application: functional components and class components.
Read more >React Native: Functional and Class Components - Medium
Class components are JavaScript ES6 classes which are extended from a base class called React.Component. Class components are referred as Stateful as they...
Read more >React Fundamentals - React Native
This short introduction to React can help you get started or get refreshed. ... Function Component; Class Component ...
Read more >Component - React Docs
Component is the base class for the React components defined as JavaScript classes. Class components are still supported by React, but we don't...
Read more >React Class Components - W3Schools
Create a Class Component When creating a React component, the component's name must start with an upper case letter. The component has to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I personally don’t see the need here and won’t put time into it, but feel free to come up with a PR. The constraints are that it needs to behave quite close to the current solution and be entirely optimized out in prod builds.
I’ll close this - essentially
dataAttributeBindings
(which ETS adds alldata-test-
attributes to automatically) is only necessary as currently component templates define inner HTML rather than outer so thatdataAttributeBindings
is the only way to get thedata-test
attributes on the component’s outer element. With the new component model where templates define the component’s outer HTML that is no longer necessary and thedata-test
attribute can be added to the component’s template directly.In general, I’d advice against using a fixed
data-test-
attribute per component that is defined inside the component (be it the component’s .js or .hbs) as that makes the tests using the attribute depend on internals of the component and the fact that a specific component is used. What you should do instead is passdata-test-
attributes into the component from the context in that the component is invoked - after all, you would usually want to use differentdata-test-
attributes for different invokations of the same component: