LESS pseudoclass inside a mixin fix

This commit is contained in:
Hanabishi 2019-04-22 17:59:35 +05:00
parent c374263b5a
commit ed7138e598
5 changed files with 12 additions and 2 deletions

View File

@ -334,7 +334,7 @@ Beautifier.prototype.beautify = function() {
}
}
} else if (this._ch === ":") {
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend) {
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel < 1) {
// 'property: value' delimiter
// which could be in a conditional group query
this.print_string(':');

View File

@ -10728,6 +10728,9 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea
'}\n' +
'.mymixin(@color: #ccc; @border-width: 1px) {\n' +
' border: @border-width solid @color;\n' +
'}\n' +
'strong {\n' +
' &:extend(a:hover);\n' +
'}');

View File

@ -358,7 +358,8 @@ class Beautifier:
if (insideRule or enteringConditionalGroup) and \
not (self._input.lookBack('&') or
self.foundNestedPseudoClass()) and \
not self._input.lookBack('(') and not insideAtExtend:
not self._input.lookBack('(') and not insideAtExtend and \
parenLevel < 1:
# 'property: value' delimiter
# which could be in a conditional group query
self.print_string(":")

View File

@ -10603,6 +10603,9 @@ class CSSBeautifierTest(unittest.TestCase):
'}\n' +
'.mymixin(@color: #ccc; @border-width: 1px) {\n' +
' border: @border-width solid @color;\n' +
'}\n' +
'strong {\n' +
' &:extend(a:hover);\n' +
'}')

View File

@ -1543,6 +1543,9 @@ exports.test_data = {
'}',
'.mymixin(@color: #ccc; @border-width: 1px) {',
' border: @border-width solid @color;',
'}',
'strong {',
' &:extend(a:hover);',
'}'
]
}]