* Implement new hydration optimization
During hydration, greedily pick nodes that exist in the original HTML that should not be detached.
Detach the rest.
* Implement optimal reordering during hydration
During hydration we track the order in which children are claimed.
Afterwards, rather than reordering them greedily one-by-one, we reorder all claimed children during the first append optimally.
The optimal reordering first finds the longest subsequence of children that have been claimed in order.
These children will not be moved.
The rest of the children are reordered to where they have to go.
This algorithm is guaranteed to be optimal in the number of reorderings.
The hydration/head-meta-hydrate-duplicate test sample has been modified slightly.
The order in which the <title> tag is being generated changed, which does not affect correctness.
* Fix issue potentially causing extra reorders
Not sorting children before executing the `insertBefore` calls in `init_hydrate` potentially caused extra `insertBefore` calls in `append`
* Simplify`init_hydrate` sorting logic
A recent refactoring commit where the constructor definition was moved to an interface disconnected the props relationship of the props that are passed in the constructor and the instance props
Fixes#6291Fixes#6345
Both writable and readable initialized without any arguments are already valid, but TS complains about it. This makes both allowed to be emptily initialized. It's also possible to invoke readable with one argument only.
* Improve SSR hydration performance
- Fixes#4308 by avoiding de- and reattaching nodes during hydration
- Turns existing append, insert and detach methods into "upserts"
The new "hydration mode" was added in order to maintain the detach by
default behavior during hydration. By tracking which nodes are claimed
during hydration unclaimed nodes can then removed from the DOM at the
end of hydration without touching the remaining nodes.
Co-authored-by: Jonatan Svennberg <jonatan.svennberg@gmail.com>
* Allow to customize the css scope class
* Pass component name to scope class generator
* Move Stylesheet arguments into an object
* Refactor to cssHash
* Please the almighty linter
* pass hash function to cssHash
* update test
* document cssHash option
Co-authored-by: Christian Kaisermann <christian@kaisermann.me>
* call onDestroy when disconnected
* lifecycle hooks and custom elements
- Call onMount in connectedCallback for customElements
- register onMount return values as on_disconnect-callbacks for customElements
- run on_disconnect callbacks in disconnectedCallback
* do not reset on_mount so that it can fire again if reinserted
* simpler isCustomElement & skip extra function call
- pass options.customElement down to mount_component
- remove expensive isCustomElement check
- only call add_render_callback if not customElement
Co-authored-by: Pontus Lundin <pontus.lundin@ica.se>