Skip to content

feat(attribute): Add HasAs trait and as() method to manage as attribute for HTML elements.#42

Merged
terabytesoftw merged 2 commits into
mainfrom
feature_17
Jan 30, 2026
Merged

feat(attribute): Add HasAs trait and as() method to manage as attribute for HTML elements.#42
terabytesoftw merged 2 commits into
mainfrom
feature_17

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Jan 30, 2026

Pull Request

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

Summary by CodeRabbit

  • New Features

    • Added support for the HTML as attribute (audio, document, embed, fetch, font, image, object, script, style, track, video, worker) so preload-type can be specified.
  • Behavior

    • Setting as is immutable, accepts string/enum/null to set or unset, and validates allowed tokens (throws on invalid values).
  • Tests

    • Added unit tests covering default state, immutability, setting/unsetting, rendering, and validation.

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

@terabytesoftw terabytesoftw added the enhancement New feature or request label Jan 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Adds support for the HTML as attribute: new HasAs trait with immutable as() method, AsValue enum for valid tokens, Attribute::AS enum case, tests and a changelog entry documenting the addition.

Changes

Cohort / File(s) Summary
Core Implementation
src/HasAs.php, src/Values/AsValue.php, src/Values/Attribute.php
Adds HasAs trait with `as(string
Tests & Providers
tests/HasAsTest.php, tests/Support/Provider/AsProvider.php
New PHPUnit tests covering immutability, default/no-op behavior, setting/unsetting, rendered output, and validation errors; provider supplies enum and scalar cases.
Changelog
CHANGELOG.md
Documents the new HasAs trait and as() method under 0.5.3 unreleased section.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A new attribute hops in with flair,
HasAs arrives — tidy, light as air,
Audio, fonts, scripts all take their place,
Immutable hops keep a steady pace,
I nibble bugs and dance — code's cozy space.

🚥 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 describes the main change: adding a HasAs trait and as() method to manage the as attribute for HTML elements, which is directly reflected in the changeset.

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

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

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.

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