Skip to content

feat(attribute): Enhance HasAria, HasData, and HasEvents traits to support prefix attributes aria-, data-, and on.#83

Merged
terabytesoftw merged 3 commits intomainfrom
feature_45
Feb 15, 2026
Merged

feat(attribute): Enhance HasAria, HasData, and HasEvents traits to support prefix attributes aria-, data-, and on.#83
terabytesoftw merged 3 commits intomainfrom
feature_45

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

Pull Request

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

… to support prefix attributes `aria-`, `data-`, and `on`.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 15, 2026

Warning

Rate limit exceeded

@terabytesoftw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5b6ea41 and 8c87f23.

📒 Files selected for processing (3)
  • src/Global/HasAria.php
  • src/Global/HasData.php
  • src/Global/HasEvents.php
📝 Walkthrough

Walkthrough

Refactors HasAria, HasData, and HasEvents traits to use prefix-aware attribute helpers: bulk methods accept an optional prefix and trait-specific add/values/remove methods delegate to generic methods with 'aria-', 'data-', or 'on' prefixes. Test providers gain "without prefix" cases; changelog updated.

Changes

Cohort / File(s) Summary
Trait Prefix-Aware Refactoring
src/Global/HasAria.php, src/Global/HasData.php, src/Global/HasEvents.php
Docblocks updated to add an optional prefix param for bulk attribute helpers (attributes, remove, set). Trait-specific methods (add*/attributes/remove*) now delegate to the generic methods with explicit prefixes ('aria-', 'data-', 'on'). Removed import of UIAwesome\Html\Helper\Attributes and adjusted implementations accordingly.
Test Data Coverage
tests/Provider/Global/AriaProvider.php, tests/Provider/Global/DataProvider.php, tests/Provider/Global/EventProvider.php
Added "without prefix" test cases to verify that non-prefixed keys (e.g., label, click) are automatically transformed to prefixed attribute keys (aria-label, data-*, onclick) when using trait helpers.
Changelog
CHANGELOG.md
Added entry documenting enhancement: HasAria, HasData, and HasEvents traits now support prefix-aware attribute handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I hop with keys both short and long,
add 'aria-', 'data-' or 'on' where they belong.
Delegations neat, no helpers to chase,
attributes aligned in tidy place.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main enhancement: adding prefix attribute support to three traits (HasAria, HasData, HasEvents).
Description check ✅ Passed The PR description is related to the changeset, confirming this is a new feature affecting the HasAria, HasData, and HasEvents traits.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_45

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the enhancement New feature or request label Feb 15, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Global/HasEvents.php`:
- Around line 17-21: Fix the PHPDoc typo in the HasEvents trait by changing
"amd" to "and" in the `@method` description for set (the line reading "Sets a
single attribute amd returns a new instance."); do the same corrective change in
the corresponding PHPDoc blocks of the HasAria and HasData traits so the `@method`
docs for attributes, remove, and set read "...attribute and returns a new
instance." instead of "...amd returns...".
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59e6484 and 1b5261c.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • src/Global/HasAria.php
  • src/Global/HasData.php
  • src/Global/HasEvents.php
  • tests/Provider/Global/AriaProvider.php
  • tests/Provider/Global/DataProvider.php
  • tests/Provider/Global/EventProvider.php
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-01-09T16:05:15.502Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 18
File: tests/Support/Provider/Global/ContentEditableProvider.php:32-33
Timestamp: 2026-01-09T16:05:15.502Z
Learning: Preserve the original copyright year in file headers when moving PHP source files between packages within the ui-awesome repositories (e.g., from ui-awesome/html-core to ui-awesome/html-attribute). Do not update the header year to the current year; keep the original creation year as stated in the header. This applies to all PHP files throughout the repo that are moved between packages.

Applied to files:

  • tests/Provider/Global/DataProvider.php
  • tests/Provider/Global/AriaProvider.php
  • tests/Provider/Global/EventProvider.php
  • src/Global/HasData.php
  • src/Global/HasAria.php
  • src/Global/HasEvents.php
📚 Learning: 2026-02-08T20:05:36.407Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 80
File: src/HasValue.php:35-35
Timestamp: 2026-02-08T20:05:36.407Z
Learning: In the ui-awesome/html-attribute repository, for methods that accept multiple values of the same type (e.g., boolean true/false), document with a single representative example rather than exhaustively listing all variations. This keeps documentation concise while conveying the intended usage. Apply this consistently across PHP docblocks and examples.

Applied to files:

  • tests/Provider/Global/DataProvider.php
  • tests/Provider/Global/AriaProvider.php
  • tests/Provider/Global/EventProvider.php
  • src/Global/HasData.php
  • src/Global/HasAria.php
  • src/Global/HasEvents.php
📚 Learning: 2026-02-07T13:44:00.931Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 78
File: tests/Global/HasDirTest.php:92-92
Timestamp: 2026-02-07T13:44:00.931Z
Learning: In PHP test methods that start with testThrowInvalidArgumentException, do not append 'Invalid' again in the method name suffix (e.g., prefer testThrowInvalidArgumentExceptionForSettingDirValue over testThrowInvalidArgumentExceptionForSettingInvalidDirValue). The exception type already communicates invalid input, so the repeated word is redundant. Apply this convention to all similar test methods under the tests/ directory.

Applied to files:

  • tests/Provider/Global/DataProvider.php
  • tests/Provider/Global/AriaProvider.php
  • tests/Provider/Global/EventProvider.php
🧬 Code graph analysis (1)
src/Global/HasAria.php (1)
src/HasValue.php (1)
  • value (44-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
🔇 Additional comments (7)
CHANGELOG.md (1)

56-56: LGTM!

Changelog entry follows the established format and accurately describes the enhancement.

src/Global/HasEvents.php (1)

29-101: Clean delegation pattern with consistent prefix handling.

All three methods (addEvent, events, removeEvent) cleanly delegate to the shared setAttribute/attributes/removeAttribute helpers with the 'on' prefix. The approach is consistent with the sibling traits.

src/Global/HasAria.php (1)

29-111: LGTM!

Consistent prefix delegation for aria-* attributes. The three methods mirror the pattern in HasEvents and HasData.

src/Global/HasData.php (1)

29-108: LGTM!

Consistent prefix delegation for data-* attributes.

tests/Provider/Global/DataProvider.php (1)

190-195: LGTM!

The "without prefix" test cases consistently verify that bare keys (e.g., 'label') are automatically prefixed to 'data-label' across all three provider methods (renderAttribute, value, values).

Also applies to: 335-340, 473-477

tests/Provider/Global/AriaProvider.php (1)

190-195: LGTM!

The "without prefix" cases properly verify automatic aria- prefixing across all three provider methods.

Also applies to: 341-346, 479-483

tests/Provider/Global/EventProvider.php (1)

160-165: LGTM!

The "without prefix" cases properly verify automatic on prefixing for event attributes across all three provider methods.

Also applies to: 275-280, 361-365

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 15, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 15, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…from `HasAria`, `HasData`, and `HasEvents` traits.
@terabytesoftw terabytesoftw merged commit f2118c7 into main Feb 15, 2026
47 checks passed
@terabytesoftw terabytesoftw deleted the feature_45 branch February 15, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant