Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Update AttributesHTML to output alt attribute even if it's empty #11217

Merged

Conversation

maxime-rainville
Copy link
Contributor

AttributeHTML want to suppress attributes with falsy values.

When rendering Images and the alt attribute contains a blank string, the attribute should be rendered anyway.

Arguably this should be on ImageManipulation instead, but it seems like an sensible exception to have across the board. I haven't decided yet.

Issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original AttributesHTML was only covered by indirect tests of classes using the trait. I decided to add an explicit test.

tests/php/View/AttributesHTMLTest.php Show resolved Hide resolved
tests/php/View/AttributesHTMLTest.php Outdated Show resolved Hide resolved
tests/php/View/AttributesHTMLTest.php Outdated Show resolved Hide resolved
/** @dataProvider singleAttributeProvider */
public function testGetAttribute($name, $value, $message): void
{
$dummy = new AttributesHTMLTest\DummyAttributesHTML();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$dummy = new AttributesHTMLTest\DummyAttributesHTML();
$dummy = DummyAttributesHTML();

Import this class. Make this change throughout this file

tests/php/View/AttributesHTMLTest.php Show resolved Hide resolved
tests/php/View/AttributesHTMLTest.php Show resolved Hide resolved
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Seems good

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

PHPlinting failure

@maxime-rainville
Copy link
Contributor Author

Fixed the linting issue

@emteknetnz emteknetnz merged commit e35f12c into silverstripe:5 May 28, 2024
15 checks passed
@emteknetnz emteknetnz deleted the pulls/5/alt-attribute-html branch May 28, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants