Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/headless-component/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ State attributes are the supported CSS targeting contract.
attribute.
- Removal or rename is breaking. Additions require tests and documentation.

Use `stringifyDataAttribute` from `library/src/utils` for presence and string
Use `toDataAttributeValue` from `library/src/utils` for presence and string
attributes:

```tsx
const state: ComponentNameState = useComponentNameBase_unstable(props, ref);

// Applied after consumer props so base state cannot be misrepresented.
state.root['data-disabled'] = stringifyDataAttribute(state.disabled);
state.root['data-disabled'] = toDataAttributeValue(state.disabled);

return state;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ Example (simplified):
```tsx
const state = useButton(props, ref);

// stringifyDataAttribute: returns undefined (omits the attribute) for falsy presence
// attributes, or the string value ("true"/"false"/enum) for boolean/tri-state attributes.
// toDataAttributeValue: returns '' (attribute present) for true, undefined (attribute
// omitted) for false, and the stringified value for enum/tri-state attributes.
Object.assign(state.root, {
'data-disabled': stringifyDataAttribute(state.disabled),
'data-disabled-focusable': stringifyDataAttribute(state.disabledFocusable),
'data-icon-only': stringifyDataAttribute(state.iconOnly),
'data-disabled': toDataAttributeValue(state.disabled),
'data-disabled-focusable': toDataAttributeValue(state.disabledFocusable),
'data-icon-only': toDataAttributeValue(state.iconOnly),
});

return state;
Expand Down
Loading