Skip to content

feat(attribute): Add HasFetchpriority trait and fetchpriority() method to manage fetchpriority attribute for HTML/SVG elements.#21

Merged
terabytesoftw merged 2 commits into
mainfrom
feature_7
Jan 10, 2026
Merged

feat(attribute): Add HasFetchpriority trait and fetchpriority() method to manage fetchpriority attribute for HTML/SVG elements.#21
terabytesoftw merged 2 commits into
mainfrom
feature_7

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Jan 10, 2026

Pull Request

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

Summary by CodeRabbit

  • New Features

    • Added fetchpriority attribute support for HTML/SVG with three priorities (auto, high, low) and an immutable API to set/unset it.
  • Tests

    • Added comprehensive tests covering rendering, immutability, valid values, and invalid-value errors.
  • Documentation

    • Changelog updated documenting the new fetchpriority capability.

✏️ Tip: You can customize this high-level summary in your review settings.

…ethod to manage `fetchpriority` attribute for HTML/SVG elements.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

Adds a new HasFetchpriority trait and a Fetchpriority enum to manage the HTML/SVG fetchpriority attribute, plus tests, a test data provider, and a changelog entry. The trait provides an immutable fetchpriority() API with validation against the enum.

Changes

Cohort / File(s) Change Summary
Core Implementation
src/HasFetchpriority.php, src/Values/Fetchpriority.php
New trait HasFetchpriority with immutable `fetchpriority(string
Tests
tests/HasFetchpriorityTest.php, tests/Support/Provider/FetchpriorityProvider.php
New PHPUnit test class covering unset/set behavior, immutability, rendering, and invalid-value exceptions; new test provider supplying static and enum-backed cases.
Documentation
CHANGELOG.md
Added changelog entry documenting the new trait and method.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

enhancement

Poem

🐰 I nibble on code with eager delight,
A trait to fetch priorities day and night,
Enums align tokens, tests hop in view,
Immutable changes, tidy and true—
Hooray for attributes, snug and bright! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: introducing a HasFetchpriority trait and fetchpriority() method for managing the fetchpriority attribute.

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


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e290e87 and 7d91666.

📒 Files selected for processing (1)
  • CHANGELOG.md
🧰 Additional context used
🧠 Learnings (1)
📚 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
⏰ 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)
  • GitHub Check: linter / Super Linter
  • GitHub Check: linter / Super Linter
🔇 Additional comments (1)
CHANGELOG.md (1)

12-12: LGTM!

The changelog entry is well-formatted, correctly placed in the "0.5.0 Under development" section, and follows the established conventions (proper backticks for identifiers, correct PR reference, and contributor attribution).


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.

@terabytesoftw terabytesoftw added the enhancement New feature or request label Jan 10, 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 @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

📥 Commits

Reviewing files that changed from the base of the PR and between 1c77746 and e290e87.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/HasFetchpriority.php
  • src/Values/Fetchpriority.php
  • tests/HasFetchpriorityTest.php
  • tests/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.php
  • src/Values/Fetchpriority.php
  • src/HasFetchpriority.php
  • tests/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::oneOf against the Fetchpriority enum
  • 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 HasFetchpriority trait:

  • 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 EnumDataGenerator

The 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 Fetchpriority enum 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.

Comment thread CHANGELOG.md Outdated
@terabytesoftw terabytesoftw merged commit 67d029f into main Jan 10, 2026
30 checks passed
@terabytesoftw terabytesoftw deleted the feature_7 branch January 10, 2026 22:34
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