Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Script Tag Behavior #628

Closed
2 tasks
Archmonger opened this issue Jan 29, 2022 · 3 comments
Closed
2 tasks

Update Script Tag Behavior #628

Archmonger opened this issue Jan 29, 2022 · 3 comments
Labels
priority-2-moderate Should be resolved on a reasonable timeline. type-feature About new capabilities
Milestone

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Jan 29, 2022

Current Situation

Currently the script tag always expects scripts to be structured as a effect hook...

// this is run on every render
() => {
  // this is run once the script is loaded and each time its content changes
  return () => {
    // this is run when the script is unloaded (i.e. it's removed from the tree) or just before its content changes
  }
}

Proposed Actions

The script tag should behave as a normal script by default

Utilize one of the following designs

  1. A parameter to utilize a destructor.
    • It could possibly be a kwarg called destructor="...", which is the name of a JavaScript function within this script's scope that will be called on unload
    • Alternatively, could be a boolean flag such as returns_destructor to denote the script is a singleton function with a destructor
  2. Instead of assuming the script is like an effect, we should be able to check if the script evals to a function, and if it does, we'll call it like an effect

Work Items

  • Develop a method to create normal scripts
  • Consider adding support for a src=... tag, if it does not exist
@Archmonger Archmonger added the flag-triage Not prioritized. label Jan 29, 2022
@rmorshea rmorshea added priority-2-moderate Should be resolved on a reasonable timeline. type-feature About new capabilities and removed flag-triage Not prioritized. labels Jan 29, 2022
@rmorshea rmorshea added this to the 1.0 milestone Jan 29, 2022
@Archmonger
Copy link
Contributor Author

@rmorshea Was this resolved in #632 ?

@rmorshea
Copy link
Collaborator

rmorshea commented Feb 2, 2022

Yup. Good catch.

@rmorshea rmorshea closed this as completed Feb 2, 2022
@Archmonger
Copy link
Contributor Author

Confirmed that it works great for my sign out (window.location.reload) button scenario!

Archmonger/Conreq@28f4883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-2-moderate Should be resolved on a reasonable timeline. type-feature About new capabilities
Projects
None yet
Development

No branches or pull requests

2 participants