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

Make NavigationDestination and NavigationHistoryEntry constructible #176

Open
domenic opened this issue Oct 15, 2021 · 0 comments
Open

Make NavigationDestination and NavigationHistoryEntry constructible #176

domenic opened this issue Oct 15, 2021 · 0 comments
Labels
addition A proposed addition which could be added later without impacting the rest of the API

Comments

@domenic
Copy link
Collaborator

domenic commented Oct 15, 2021

@tbondwilkinson mentions that it's helpful to sometimes create synthetic versions of these objects for unit testing purposes. This would also align with https://w3ctag.github.io/design-principles/#constructors .

I think we would not do any significant validation on the inputs, e.g. we would not validate key/id at all besides casting the input to a string. (Possible validations would include checking that they're valid UUIDs, checking that they're valid v4 UUIDs, and checking that they're appropriate key/id UUIDs of actual history entries.)

The only potential downside of this is that unsuspecting code might end up getting synthetic NavigationDestination or NavigationHistoryEntry instances that break the invariants the code usually relies on. E.g. navigation.entries()[entry.index] === entry would always be false if entry is synthetic.

@domenic domenic added the addition A proposed addition which could be added later without impacting the rest of the API label Nov 4, 2021
@domenic domenic changed the title Make AppHistoryDestination and AppHistoryEntry constructible Make NavigationDestination and NavigationHistoryEntry constructible Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition A proposed addition which could be added later without impacting the rest of the API
Projects
None yet
Development

No branches or pull requests

1 participant