Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 60a0540

Browse files
authored
Migration from deprecated HTML attributes: properly add 'px'
https://phabricator.wikimedia.org/T394893
1 parent 495f6d6 commit 60a0540

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/PageParser.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,14 @@ protected function deprecatedAttributes( $name, $attribute, $isCss = true ) {
388388
/** @var DOMElement $node */
389389
foreach ( $nodes as $node ) {
390390
if ( $attribute != null ) {
391+
$value = trim( $node->getAttribute( $name ) );
391392
if ( $isCss ) {
392-
$node->setAttribute( 'style', $attribute . ':' . $node->getAttribute( $name ) . '; ' . $node->getAttribute( 'style' ) );
393+
if ( is_numeric( $value ) ) {
394+
$value .= 'px'; // CSS requires the pixel unit
395+
}
396+
$node->setAttribute( 'style', $attribute . ':' . $value . '; ' . $node->getAttribute( 'style' ) );
393397
} else {
394-
$node->setAttribute( $attribute, $node->getAttribute( $name ) );
398+
$node->setAttribute( $attribute, $value );
395399
}
396400
}
397401
$node->removeAttribute( $name );

0 commit comments

Comments
 (0)