Skip to content

Commit

Permalink
Functions: Let length() function count only Expression or Value
Browse files Browse the repository at this point in the history
Henceforth the check against HasValueProperty is not required
and could be simplified to check only against valid concrete
implementations. Only Expression and Value can have array values.

Other type will gracefully produce "1" as result, same as before.

Bug: T327082
Change-Id: I812a7e54ad2d9ed955043381a136ddc646cb0b7b
  • Loading branch information
polishdeveloper authored and Krinkle committed Nov 20, 2023
1 parent 1ee00be commit b60b3d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ public function extract( $values, $index ) {
}

public function length( $values ) {
$n = ( $values instanceof Less_Tree_HasValueProperty && is_array( $values->value ) ) ?
$n = ( $values instanceof Less_Tree_Expression || $values instanceof Less_Tree_Value ) ?
count( $values->value ) : 1;
return new Less_Tree_Dimension( $n );
}
Expand Down

0 comments on commit b60b3d7

Please sign in to comment.