Fix race condition between script load and rerenders #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9 by:
src
changes - see below for why attributes currently weren't skipping any effect calls anyhowis-unmounted
is implemented anyhow (so we don't need the package)Attributes currently weren't equal for any call to this hook. Objects are never strict equal unless they're the same object, never true for two reasons:
...attributes
, which creates a new object (via__rest
in the compiled output)I've aded some tests to cover unmounting and onload.
How attributes could be supported
The above demonstrates that attributes are currently not equal for any two calls. I'm unsure how often that's a use-case people want though - I'd assume most would be loading a static src, and a small % a dynamic
src
which is handled correctly.However, if it was a desired feature it would be necessary to:
script-change-key
which the caller could define.Finally - the same goal could be achieved with just
src
by adding superfluous query strings to thesrc
to force a change, e.gconst src = "https://cdn.com/some-script?k=" + someDynamicValue
.