Skip to content

Fix issue with missing default values#773

Open
tpaulshippy wants to merge 1 commit intohotwired:mainfrom
tpaulshippy:issue-772
Open

Fix issue with missing default values#773
tpaulshippy wants to merge 1 commit intohotwired:mainfrom
tpaulshippy:issue-772

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

1 participant