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

Svelte 5: Document $svelte.is(a,b) using Object.is(a,b). #12167

Closed
willnationsdev opened this issue Jun 24, 2024 · 2 comments · Fixed by #12180
Closed

Svelte 5: Document $svelte.is(a,b) using Object.is(a,b). #12167

willnationsdev opened this issue Jun 24, 2024 · 2 comments · Fixed by #12180
Assignees

Comments

@willnationsdev
Copy link

willnationsdev commented Jun 24, 2024

Describe the problem

The current documentation for $state.is equates $state.is() to an === operator when the actual PR's underlying implementation uses Object.is(a, b).

Describe the proposed solution

This information should be surfaced to the documentation since it does not yield identical behavior to the === operator.

Importance

nice to have

@dummdidumm
Copy link
Member

I don't understand point 1 and 2. The example in the docs is assigning bar to foo.bar and is then comparing those two objects which would be equal if it wasn't for the proxy.

@willnationsdev
Copy link
Author

Oh wow. 🤦

Idk how that just went right over my head, but every time I looked at this code sample, I just kept thinking it was the {} within the $state({}) itself that was being compared, not the bar property manifested on it. And having just tested it myself now, I can see that even with another empty object, it is properly handling reference equality. Please ignore those points. Just a brainfart. Will update the question to just ask for clarification of the Object.is bit.

@willnationsdev willnationsdev changed the title Svelte 5: Document $svelte.is performing a structural equality comparison. Svelte 5: Document $svelte.is using Object.is() Jun 24, 2024
@willnationsdev willnationsdev changed the title Svelte 5: Document $svelte.is using Object.is() Svelte 5: Document $svelte.is(a,b) using Object.is(a,b). Jun 24, 2024
@trueadm trueadm self-assigned this Jun 24, 2024
dummdidumm added a commit to sveltejs/svelte.dev that referenced this issue Jun 25, 2024
Rich-Harris pushed a commit to sveltejs/svelte.dev that referenced this issue Jun 25, 2024
* overview

* getting started

* component fundamentals

* basic markup

* control flow

* snippets

* styles and classes

* transitions and animations (WIP, needs motion and tweened, reference should have more details so we can point to it)

* actions WIP (add $effect)

* bindings

* special elements

* data fetching (WIP, what else can we put there?)

* stores

* imperative component api

* reactivity fundamentals

* contex

* lifecycle hooks

* state

* debugging

* fix

* more details on $state.is, closes sveltejs/svelte#12167

* side effects

* typescript

related: sveltejs/svelte#11502

* custom elements

* events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants