Skip to content

Commit

Permalink
Return updated attribute value if present
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jan 4, 2023
1 parent ec21489 commit b559cd4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/experimental/html/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,19 @@ public function get_attribute( $name ) {
}

$comparable = strtolower( $name );

// If we have an update for this attribute, return the updated value.
if ( isset ( $this->attribute_updates[ $comparable ] ) ) {
$attribute = trim( $this->attribute_updates[ $comparable ]->text );
// Is this a boolean attribute?
if ( $attribute === $comparable ) {
return true;
}

// $attribute is a 'name="value"' string, so we extract the value.
return substr( $attribute, strlen( $comparable ) + 2, -1 );
}

if ( ! isset( $this->attributes[ $comparable ] ) ) {
return null;
}
Expand Down

1 comment on commit b559cd4

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3838235373
📝 Reported issues:

Please sign in to comment.