Skip to content

Commit

Permalink
Clarify only :any and :atom expect the value to be nil, see #3602
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 5, 2025
1 parent 4671fba commit 38be0a1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/phoenix_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,15 @@ defmodule Phoenix.Component do
</div>
```
The following attribute values have special meaning:
The following attribute values have special meaning on HTML tags:
* `true` - if a value is `true`, the attribute is rendered with no value at all.
For example, `<input required={true}>` is the same as `<input required>`;
* `false` or `nil` - if a value is `false` or `nil`, the attribute is omitted.
Note the `class` and `style` attributes in regular HTML tags will be rendered
as empty strings, instead of ommitted, which has the same effect and allows
for rendering optimizations.
Note the `class` and `style` attributes will be rendered as empty strings,
instead of ommitted, which has the same effect as not rendering them, but
allows for rendering optimizations.
* `list` (only for the `class` attribute) - each element of the list is processed
as a different class. `nil` and `false` elements are discarded.
Expand Down Expand Up @@ -1878,7 +1878,7 @@ defmodule Phoenix.Component do
| Name | Description |
|-----------------|----------------------------------------------------------------------|
| `:any` | any term |
| `:any` | any term (including `nil`) |
| `:string` | any binary string |
| `:atom` | any atom (including `true`, `false`, and `nil`) |
| `:boolean` | any boolean |
Expand All @@ -1889,6 +1889,8 @@ defmodule Phoenix.Component do
| `:global` | any common HTML attributes, plus those defined by `:global_prefixes` |
| A struct module | any module that defines a struct with `defstruct/1` |
Note only `:any` and `:atom` expect the value to be set to `nil`.
### Options
* `:required` - marks an attribute as required. If a caller does not pass the given attribute,
Expand Down

0 comments on commit 38be0a1

Please sign in to comment.