Closed marconi1992 closed 4 years ago
Can you elaborate a bit more on why this is needed?
(It'd also need tests and docs)
Sure @ljharb. For example, hypernova provides the fromScript helper that I'm using in my library.
There's no way to know which are the correct keys. They need to be hardcoded.
fromScript({
`hypernova-key`: key,
`hypernova-id`: id,
});
I think is a good practice to export them to do something like this:
import { DATA_KEY, DATA_ID } from 'hypernova'
fromScript({
[DATA_KEY]: key,
[DATA_ID]: id,
});
Otherwise, the helper is prone to errors if the developer makes a typo. Does it make sense?
@marconi1992 that makes perfect sense! I'd be happy to merge this after some basic tests and docs are added.
@ljharb I added a simple test and how to use them in the README.md
. Let me know if something is missing.
Context:
Currently, I'm working on a framework using Hypernova and I've been writing some custom bindings for other libraries like Vue.js, Svelte, etc.
I'm getting the
data-*
values, but I think I need a way to warranty that the data attributes will be the same thathypernova
is using if they change in the future.https://github.com/ara-framework/hypernova-redom/blob/feat/render-client/src/index.js#L18