Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Enable component specific JS #2

Open
2 tasks
Fleuv opened this issue Aug 26, 2020 · 0 comments
Open
2 tasks

Enable component specific JS #2

Fleuv opened this issue Aug 26, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@Fleuv
Copy link
Contributor

Fleuv commented Aug 26, 2020

Is your feature request related to a problem? Please describe.
Currently the software doesn't make it easy to get to the element of the component from JavaScript, just like with CSS.

Describe the solution you'd like
It would be nice to use a predefined variable which always references to the root element of the component. This reference can be generated programmatically and injected to top of the script. However to avoid variable collisions it would be smart to force the developer to create and export a function, where the software passes the reference to.

Acceptance criteria

  • The reference is component independent.
  • JavaScript code is imported and executed as a function with one argument.

Test data
Creating a script, should also create a file so it can be imported. JavaScript code could look like this:

export default function (element) {
    // Do something with the element
}

Eventually the software will do something like this, similar to how it's done with CSS:

require('./My component.js')(document.querySelector('.MyComponent-abc123'));
@Fleuv Fleuv added the enhancement New feature or request label Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant