Skip to content

Commit 7cdc10e

Browse files
author
Peter Stenger
committed
docs: document custom tag boolean attributes
1 parent a9c7125 commit 7cdc10e

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,18 @@ Schemas validate the tag's flat attribute object. The tag name is implicit from
376376
}
377377
```
378378

379-
Attribute values are coerced by JSON Schema (`"2"` can satisfy an integer, valueless attributes become `true`). Attribute values containing mustache are treated as unknown runtime values, so value-dependent schema errors are waived while presence and unknown-attribute checks still run.
379+
Attribute values are coerced by JSON Schema (`"2"` can satisfy an integer, boolean attributes become `true`). Attribute values containing mustache are treated as unknown runtime values, so value-dependent schema errors are waived while presence and unknown-attribute checks still run.
380+
381+
HTML boolean attributes are allowed on custom tags by default, so `<pl-answer correct>` validates as `{ "correct": true }`. To require explicit values for custom tag attributes by default, set `customTagDefaults.allowBooleanAttributes` to `false`; individual custom tag entries can opt back in:
382+
383+
```jsonc
384+
{
385+
"customTagDefaults": { "allowBooleanAttributes": false },
386+
"customTags": [{ "name": "pl-answer", "allowBooleanAttributes": true }],
387+
}
388+
```
389+
390+
When boolean attributes are disabled for a custom tag, `<pl-answer correct>` reports `Attribute "correct" on <pl-answer> must have a value.` Ordinary HTML boolean attributes such as `<input disabled>` are not affected by this custom tag setting.
380391

381392
Custom tags can also declare parent-owned child schemas. Child schemas validate a direct child tag's flat attribute object only in the context of that parent:
382393

@@ -470,6 +481,7 @@ Schema diagnostics are phrased in HTML/element terms rather than JSON-Schema voc
470481
| strict unlisted child | `<pl-multiple-choice> only allows these child elements: <pl-answer>.` |
471482
| child-only tag outside its parent | `<pl-answer> may only appear as a direct child of these parent elements: <pl-multiple-choice>.` |
472483
| child `additionalProperties` | `Unknown attribute "ranking" on <pl-answer> inside <pl-multiple-choice>.` |
484+
| custom tag boolean attribute | `Attribute "correct" on <pl-answer> must have a value.` |
473485
| `properties.display.enum` | `Attribute "display" on <pl-multiple-choice> must be one of: "block", "inline".` |
474486
| `properties.size.type: "integer"` | `Attribute "size" on <pl-multiple-choice> must be integer.` |
475487
| `properties.weight.minimum: 0` | `Attribute "weight" on <pl-multiple-choice> must be >= 0.` |

docs/superpowers/specs/2026-05-15-valueless-custom-tag-attributes-design.md renamed to docs/superpowers/specs/2026-05-15-boolean-custom-tag-attributes-design.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ Child tag entries do not inherit the setting from their parent tag entry. They i
7070

7171
If the same child tag is declared under different parents, each child entry may use a different `allowBooleanAttributes` value, matching the existing parent-specific child schema behavior.
7272

73+
Example with boolean attributes disabled by default for custom tags, but allowed for `<pl-answer>`:
74+
75+
```jsonc
76+
{
77+
"customTagDefaults": { "allowBooleanAttributes": false },
78+
"customTags": [{ "name": "pl-answer", "allowBooleanAttributes": true }]
79+
}
80+
```
81+
7382
## Validation Behavior
7483

7584
When the resolved setting for a custom tag entry is `false`, every literal HTML boolean attribute on that element is a `customTagSchema` diagnostic.
@@ -107,6 +116,8 @@ The diagnostic anchors to the boolean attribute node. The check runs before JSON
107116

108117
Dynamic or mustache-shaped attributes are unaffected unless they parse as ordinary HTML boolean attributes. For example, `<pl-answer correct="{{value}}">` has a value and is not rejected by this option.
109118

119+
Ordinary HTML boolean attributes such as `<input disabled>` are not affected because the option applies only to configured custom tag entries.
120+
110121
## TypeScript API
111122

112123
Keep the existing default ergonomic API:

0 commit comments

Comments
 (0)