Skip to content

Commit

Permalink
Merge "Fix unexpected duplicating of uncalled mixin rules"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Apr 24, 2024
2 parents 49c5b9e + c047afe commit 299a47f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Less/Tree/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ public function CacheElements() {
$css .= $v->value;
continue;
}

if ( isset( $v->value->value ) && !is_object( $v->value->value ) ) {
$css .= $v->value->value;
continue;
}

if ( ( $v->value instanceof Less_Tree_Selector || $v->value instanceof Less_Tree_Variable )
|| !is_string( $v->value->value ) ) {
$this->cacheable = false;
}
if ( isset( $v->value->value ) && !is_object( $v->value->value ) ) {
$css .= $v->value->value;
return;
}
}

Expand Down
21 changes: 21 additions & 0 deletions test/Fixtures/less.php/css/T363076-mixins-copies-rules.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.btn {
color: blue;
font-weight: bold;
}
.btn[title] {
background: lightgreen;
}
.btn[disabled] {
cursor: not-allowed;
color: red;
}
.btn[test] {
background-color: pink;
}
.btn-specific {
color: blue;
font-weight: bold;
}
.btn-specific[title] {
background: lightgreen;
}
19 changes: 19 additions & 0 deletions test/Fixtures/less.php/less/T363076-mixins-copies-rules.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.btn {
color: blue;
font-weight: bold;

&[title] {
background: lightgreen;
}
}
.btn[disabled] {
cursor: not-allowed;
color: red;
}
.btn[test] {
background-color: pink;
}

.btn-specific {
.btn();
}

0 comments on commit 299a47f

Please sign in to comment.