Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Make DATA_KEY and DATA_ID attributes importable #159

Merged
merged 1 commit into from
Sep 15, 2019

Conversation

marconi1992
Copy link
Contributor

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 that hypernova is using if they change in the future.

https://github.com/ara-framework/hypernova-redom/blob/feat/render-client/src/index.js#L18

@ljharb
Copy link
Collaborator

ljharb commented Aug 17, 2019

Can you elaborate a bit more on why this is needed?

(It'd also need tests and docs)

@marconi1992
Copy link
Contributor Author

marconi1992 commented Aug 20, 2019

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?

@ljharb
Copy link
Collaborator

ljharb commented Sep 15, 2019

@marconi1992 that makes perfect sense! I'd be happy to merge this after some basic tests and docs are added.

@marconi1992
Copy link
Contributor Author

@ljharb I added a simple test and how to use them in the README.md. Let me know if something is missing.

@ljharb ljharb merged commit 0971f5d into airbnb:master Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants