feat(attribute): Add HasFetchpriority trait and fetchpriority() method to manage fetchpriority attribute for HTML/SVG elements.#21
Conversation
…ethod to manage `fetchpriority` attribute for HTML/SVG elements.
📝 WalkthroughWalkthroughAdds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-01-09T16:05:25.443ZApplied to files:
⏰ 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). (2)
🔇 Additional comments (1)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @CHANGELOG.md:
- Line 12: Fix the typo in the changelog entry by replacing the leading "Ebh"
with "Enh" so the entry reads "Enh #21: Add `HasFetchpriority` trait and
`fetchpriority()` method to manage `fetchpriority` attribute for HTML/SVG
elements (@terabytesoftw)"; ensure no other formatting changes are made.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
CHANGELOG.mdsrc/HasFetchpriority.phpsrc/Values/Fetchpriority.phptests/HasFetchpriorityTest.phptests/Support/Provider/FetchpriorityProvider.php
🧰 Additional context used
🧠 Learnings (2)
📚 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/Support/Provider/FetchpriorityProvider.phpsrc/Values/Fetchpriority.phpsrc/HasFetchpriority.phptests/HasFetchpriorityTest.php
📚 Learning: 2026-01-09T16:05:25.443Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 18
File: tests/Support/Provider/Global/ContentEditableProvider.php:32-33
Timestamp: 2026-01-09T16:05:25.443Z
Learning: In the ui-awesome/html-attribute repository, when files are moved from the ui-awesome/html-core package (or other packages), the original copyright year in the file headers should be preserved rather than updated to the current year, as these represent the year the code was originally created.
Applied to files:
CHANGELOG.md
🧬 Code graph analysis (2)
tests/Support/Provider/FetchpriorityProvider.php (2)
tests/Support/EnumDataGenerator.php (2)
EnumDataGenerator(24-85)cases(40-60)src/Global/HasClass.php (1)
class(78-89)
tests/HasFetchpriorityTest.php (4)
tests/Support/Provider/FetchpriorityProvider.php (1)
FetchpriorityProvider(34-93)src/HasFetchpriority.php (1)
fetchpriority(63-68)src/Exception/Message.php (1)
getMessage(70-73)tests/Support/EnumDataGenerator.php (1)
cases(40-60)
⏰ 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). (7)
- GitHub Check: phpunit / PHP 8.2-ubuntu-latest
- GitHub Check: phpunit / PHP 8.1-windows-2022
- GitHub Check: phpunit / PHP 8.3-ubuntu-latest
- GitHub Check: phpunit / PHP 8.4-ubuntu-latest
- GitHub Check: phpunit / PHP 8.1-ubuntu-latest
- GitHub Check: linter / Super Linter
- GitHub Check: linter / Super Linter
🔇 Additional comments (4)
src/HasFetchpriority.php (1)
1-69: LGTM! Well-implemented trait with proper validation and immutability.The trait follows established patterns in the codebase with:
- Correct validation using
Validator::oneOfagainst theFetchpriorityenum- Immutable API returning a new instance
- Comprehensive documentation with usage examples
- Proper exception handling for invalid values
tests/HasFetchpriorityTest.php (1)
1-116: LGTM! Comprehensive test coverage.The test suite provides excellent coverage of the
HasFetchprioritytrait:
- Validates empty state when attribute is not set
- Confirms immutability when setting the attribute
- Uses data-driven testing for various input scenarios
- Properly tests exception handling for invalid values
tests/Support/Provider/FetchpriorityProvider.php (1)
1-93: LGTM! Well-structured test data provider.The data provider effectively combines static test cases with enum-generated cases to ensure comprehensive coverage of:
- Edge cases (empty string, null)
- Replacement scenarios
- Standard string values
- All enum cases via
EnumDataGeneratorThe descriptive test case names will facilitate debugging when tests fail.
src/Values/Fetchpriority.php (1)
1-53: LGTM! Well-defined enum with excellent documentation.The
Fetchpriorityenum correctly implements the HTML specification with:
- All three standard values:
auto,high,low- Comprehensive documentation for each case
- Appropriate warnings about performance considerations (e.g., using HIGH sparingly)
- Proper links to the HTML Living Standard
The backed enum pattern ensures type-safe attribute values while enabling clean rendering.
Pull Request
Summary by CodeRabbit
New Features
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.