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

Fix issue with missing default values #773

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpaulshippy
Copy link

Purpose

Resolves issue #772
https://stimulus.hotwired.dev/reference/values#existential-properties states the following:

The existential property for a value evaluates to true when the associated data attribute is present on the controller’s element and false when it is absent.

The exception to this defined here is when a custom default value is provided. Defaults can be provided either as a literal, or with the default property like so: { type: String, default: 'abc' }.

Approach

  1. If the type is a constant, it does not have a default.
    Example: something: String
  2. If the type has a default property, it does have a default.
    Example: something: { type: String, default: 'abc' }
  3. If the type has a type property (but not a default property), it does not have a default.
    Example: something: { type: String }
  4. Finally, if the type is a literal, it does have a default.
    Example: something: 'abc'

Tests

Unit tests with Karma

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

Successfully merging this pull request may close these issues.

1 participant