Comments (7)
ebe00d0 allows string keys to be used to pass props to DOM elements verbatim. E.g.
(d/button {"logical-id" "foo"} "Foo")
This will go out in the next release. You're welcome to use it via git deps for now.
However, again, I would strongly encourage you to migrate your tests to use data-
attributes, as it is industry best practice to do so and guarantees that your tests won't break in subtle ways later. Assuming this application (and tests) will live on for years, it's probably worth the investment now to do so.
Either way, thanks for the report! I'll close this for now. If you do try out the string keys functionality and you find any bugs, please open another issue.
from helix.
Potentially related to #9.
from helix.
For test IDs and other custom attributes that you don't want to be munged, you can prefix data-
to the beginning and it should not be camelCased. E.g.
(d/button {:data-testid "foo-button"} "Foo")
See
helix/src/helix/impl/props.cljc
Line 11 in 6d86748
aria-
and --
attributes.
Hope that helps!
from helix.
In our case, the trouble is that the tests are expecting certain elements to be identified with the property logical-id
, not e.g. data-logical-id
.
from helix.
Maybe a silly question, but could you change the tests? AFAIK best practices for DOM testing is to use data-
attributes, see https://docs.cypress.io/guides/references/best-practices#Selecting-Elements and https://testing-library.com/docs/queries/bytestid/.
The usage of data attributes for this is to ensure that future changes to the DOM spec don't end up changing the behavior of the elements you've attached the attributes to. See https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
I can think about other fixes for this, but in general it will behoove you to store and lookup this type of information in data-
attributes.
from helix.
Thanks for the information, this is helpful!
We would prefer to avoid renaming the attributes, since we are already using the non-data
-prefixed version in a ton of places, but we could do it if we have to.
We might also be able to work around this by using non-native elements (e.g. MUI Box), since the properties are passed through unchanged for those.
from helix.
That all sounds good - thanks for the fast response!
from helix.
Related Issues (20)
- Any good way to make multimethods work as component functions? HOT 8
- gensym / anonymous function syntax breaks fast refresh HOT 2
- Include resources in deps.edn :paths
- $ clj-kondo hook fails to lint & right when component is not a symbol
- The $ macro and new JSX transform HOT 14
- `wrap-fx` is public HOT 1
- Wrappers for useTransition, useDeferredValue, etc. HOT 1
- Add wrapper around createRef with atom protocols HOT 2
- How to use with uikit? HOT 2
- Running tests in nodejs with jsdom HOT 4
- Companies using Helix HOT 1
- indent metadata on helix.dom macros HOT 3
- Create use-isomorphic-layout-effect HOT 6
- Make self-hosted CLJS compatible HOT 2
- Fix indentation with CIDER HOT 3
- Release request HOT 1
- Warning: React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead. HOT 2
- `helix.dom/tags` removed HOT 2
- defnc taking pre- & post-conditions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helix.