Skip to content

fix(elements): Improve BaseInlineElement with additional traits and update related tests.#108

Merged
terabytesoftw merged 3 commits into
mainfrom
fix_mini_76
Dec 10, 2025
Merged

fix(elements): Improve BaseInlineElement with additional traits and update related tests.#108
terabytesoftw merged 3 commits into
mainfrom
fix_mini_76

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Dec 10, 2025

Pull Request

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

Summary by CodeRabbit

  • New Features

    • Inline elements gain support for additional HTML attributes: autofocus, hidden, contentEditable, direction, draggable, spellcheck, tabindex, and microdata (itemid/itemprop/itemref/itemscope/itemtype).
  • Tests

    • Added comprehensive tests verifying rendering of the new attributes on inline elements and updated assertion messages for consistency.
  • Documentation

    • Changelog updated to note the improvements and added test coverage.

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

@terabytesoftw terabytesoftw added the bug Something isn't working label Dec 10, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 10, 2025

Walkthrough

BaseInlineElement now composes eight additional attribute-related traits (autofocus, hidden, contentEditable, dir, draggable, microdata, spellcheck, tabindex). Tests for Span rendering were added/expanded to cover these attributes and microdata, and a changelog entry documenting the change was added.

Changes

Cohort / File(s) Summary
Trait composition
src/element/BaseInlineElement.php
Added composition of eight traits on BaseInlineElement: CanBeAutofocus, CanBeHidden, HasContentEditable, HasDir, HasDraggable, HasMicroData, HasSpellcheck, HasTabindex.
Test coverage
tests/html/phrasing/SpanTest.php
Added ~12 tests covering autofocus, contentEditable, dir, draggable, hidden, microdata attributes (itemid, itemprop, itemref, itemscope, itemtype), spellcheck, and tabindex; updated assertion messages and added Direction import.
Documentation
CHANGELOG.md
Added changelog entry describing the trait composition and test additions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Verify trait imports/uses and namespaces in src/element/BaseInlineElement.php.
  • Confirm each new test in tests/html/phrasing/SpanTest.php asserts correct HTML attribute rendering (including microdata attribute names and values).
  • Check updated assertion messages and the Direction import.

Possibly related PRs

Poem

🐰
I stitched new traits into a span so neat,
autofocus and dir make it complete.
Microdata and tabindex hop in line,
Tests cheered softly, green flags all fine. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 changes: improving BaseInlineElement with additional traits and updating related tests, which matches the changeset content.
✨ 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 fix_mini_76

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76fb503 and 1866508.

📒 Files selected for processing (1)
  • tests/html/phrasing/SpanTest.php (9 hunks)
⏰ 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). (13)
  • GitHub Check: Analyze (actions)
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-windows-2022
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpstan / PHP 8.4-ubuntu-latest
🔇 Additional comments (3)
tests/html/phrasing/SpanTest.php (3)

16-16: LGTM!

The Direction import is correctly added and used in the testRenderWithDir method.


61-70: Excellent test coverage for new attributes!

All twelve new test methods follow a consistent, well-structured pattern and correctly verify the rendering of the newly supported attributes (autofocus, contentEditable, dir, draggable, hidden, itemId, itemProp, itemRef, itemScope, itemType, spellcheck, tabindex). The expected HTML outputs align with HTML5 specifications, and the assertion messages are clear and descriptive.

Also applies to: 94-103, 151-160, 162-171, 192-201, 214-223, 225-234, 236-245, 247-256, 258-267, 327-336, 378-387


295-295: LGTM!

The assertion message accurately describes that both prefix() and suffix() methods are being tested together.


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b1b4e2 and b8f0b8c.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • src/element/BaseInlineElement.php (2 hunks)
  • tests/html/phrasing/SpanTest.php (9 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/element/BaseInlineElement.php (1)
src/mixin/HasAttributes.php (1)
  • attributes (57-63)
⏰ 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). (11)
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: composer-require-checker / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: easy-coding-standard / PHP 8.4-ubuntu-latest
  • GitHub Check: phpstan / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (5)
CHANGELOG.md (1)

112-112: LGTM!

The changelog entry correctly documents the improvements to BaseInlineElement and aligns with the code changes in this PR.

src/element/BaseInlineElement.php (2)

10-10: LGTM! Trait additions expand inline element capabilities.

The addition of CanBeHidden, HasContentEditable, HasDir, HasDraggable, HasMicroData, HasSpellcheck, and HasTabindex traits is appropriate. These traits correspond to global HTML attributes that are valid for inline elements, and the implementation maintains alphabetical ordering in both imports and uses.

Also applies to: 12-12, 14-15, 18-19, 21-21, 54-54, 58-58, 60-61, 64-64, 66-66, 69-69


9-9: CanBeAutofocus trait is intentionally implemented as a global attribute.

The CanBeAutofocus trait is explicitly documented as managing the global HTML autofocus attribute following the HTML specification. The trait implementation references both MDN's global_attributes/autofocus and the WHATWG HTML spec, and the test suite confirms intentional support for autofocus on inline elements like Span.

This is a valid design choice: the framework provides the API for setting autofocus on any element as a global attribute trait. Developers are responsible for ensuring they use it in compliance with HTML specifications (e.g., only on form controls or contenteditable elements in production code).

Likely an incorrect or invalid review comment.

tests/html/phrasing/SpanTest.php (2)

16-16: LGTM! Comprehensive test coverage for new attributes.

The added tests properly validate rendering of all new attributes (autofocus, contentEditable, dir, draggable, hidden, microdata attributes, spellcheck, and tabindex) on Span elements. The test structure is consistent, and assertions correctly verify the expected HTML output.

Note: The testRenderWithAutofocus test assumes that autofocus on a <span> element is valid. As noted in the BaseInlineElement.php review, please verify this is intentional.

Also applies to: 61-70, 94-103, 151-160, 162-171, 214-267, 327-336, 378-387


112-112: LGTM! Improved assertion messages.

The assertion messages have been updated for better clarity: line 112 now correctly references "dataAttributes" attribute, and line 295 properly mentions both 'prefix()' and 'suffix()' methods.

Also applies to: 295-295

Comment thread tests/html/phrasing/SpanTest.php Outdated
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: 0

🧹 Nitpick comments (1)
tests/html/phrasing/SpanTest.php (1)

112-112: Minor wording inconsistency in assertion message.

The message says "with 'dataAttributes' attribute" but refers to the dataAttributes() method rather than a single HTML attribute. For consistency with line 295 (which uses "with both 'prefix()' and 'suffix()' methods"), consider updating to "with 'dataAttributes()' method" or "with data attributes".

Apply this diff for consistency:

-            "Failed asserting that element renders correctly with 'dataAttributes' attribute.",
+            "Failed asserting that element renders correctly with 'dataAttributes()' method.",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8f0b8c and 76fb503.

📒 Files selected for processing (1)
  • tests/html/phrasing/SpanTest.php (9 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/html/phrasing/SpanTest.php (11)
src/html/phrasing/Span.php (1)
  • Span (32-53)
src/tag/BaseTag.php (2)
  • tag (317-335)
  • render (281-288)
src/attributes/CanBeAutofocus.php (1)
  • autofocus (53-59)
src/attributes/HasContentEditable.php (1)
  • contentEditable (64-83)
src/attributes/HasData.php (1)
  • dataAttributes (68-95)
src/attributes/HasDir.php (1)
  • dir (62-75)
src/attributes/HasDraggable.php (1)
  • draggable (63-82)
src/attributes/CanBeHidden.php (1)
  • hidden (53-59)
src/attributes/HasMicroData.php (5)
  • itemId (57-68)
  • itemProp (92-103)
  • itemRef (127-138)
  • itemScope (161-172)
  • itemType (195-206)
src/attributes/HasSpellcheck.php (1)
  • spellcheck (60-79)
src/attributes/HasTabindex.php (1)
  • tabIndex (57-76)
⏰ 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). (13)
  • GitHub Check: phpstan / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: easy-coding-standard / PHP 8.4-ubuntu-latest
  • GitHub Check: composer-require-checker / PHP 8.4-ubuntu-latest
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: easy-coding-standard / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (3)
tests/html/phrasing/SpanTest.php (3)

16-16: LGTM!

The import is necessary for testRenderWithDir() and correctly references the Direction enum.


61-70: LGTM!

The new test methods provide comprehensive coverage for the additional traits added to BaseInlineElement. Each test follows the established pattern, uses correct method names, and verifies the expected HTML output for the respective attributes.

Also applies to: 94-103, 151-160, 162-171, 192-201, 214-223, 225-234, 236-245, 247-256, 258-267, 327-336, 378-387


295-295: LGTM!

The updated assertion message clearly indicates that both methods are being tested and uses correct method notation.

@terabytesoftw terabytesoftw merged commit 3d7a369 into main Dec 10, 2025
43 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_76 branch December 10, 2025 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant