Skip to content

Commit c1efcf4

Browse files
committed
Change extend format to :extend(.class); - part 1 - support for stand-alone &:extend(.class);
1 parent d9f929a commit c1efcf4

File tree

7 files changed

+34
-37
lines changed

7 files changed

+34
-37
lines changed

dist/less-1.4.0.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,8 @@ less.Parser = function Parser(env) {
654654
primary: function () {
655655
var node, root = [];
656656

657-
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
658-
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
659-
$(this.extend))
657+
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
658+
$(this.mixin.call) || $(this.comment) || $(this.directive))
660659
|| $(/^[\s\n]+/) || $(/^;+/)) {
661660
node && root.push(node);
662661
}
@@ -942,15 +941,15 @@ less.Parser = function Parser(env) {
942941
extend: function() {
943942
var elements = [], e, args, index = i;
944943

945-
if (input.charAt(i) !== '+') { return; }
944+
if (!$(/^&:extend\(/)) { return; }
946945

947-
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
948-
elements.push(new(tree.Element)(null, e.slice(2), i));
946+
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
947+
elements.push(new(tree.Element)(null, e, i));
949948
}
949+
950+
expect(/^\);/);
950951

951-
if (elements.length > 0 && ($(';') || peek('}'))) {
952-
return new(tree.Extend)(elements, index);
953-
}
952+
return new(tree.Extend)(elements, index);
954953
},
955954

956955
//

dist/less-1.4.0.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/less-rhino-1.4.0.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,8 @@ less.Parser = function Parser(env) {
646646
primary: function () {
647647
var node, root = [];
648648

649-
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
650-
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
651-
$(this.extend))
649+
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
650+
$(this.mixin.call) || $(this.comment) || $(this.directive))
652651
|| $(/^[\s\n]+/) || $(/^;+/)) {
653652
node && root.push(node);
654653
}
@@ -934,15 +933,15 @@ less.Parser = function Parser(env) {
934933
extend: function() {
935934
var elements = [], e, args, index = i;
936935

937-
if (input.charAt(i) !== '+') { return; }
936+
if (!$(/^&:extend\(/)) { return; }
938937

939-
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
940-
elements.push(new(tree.Element)(null, e.slice(2), i));
938+
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
939+
elements.push(new(tree.Element)(null, e, i));
941940
}
941+
942+
expect(/^\);/);
942943

943-
if (elements.length > 0 && ($(';') || peek('}'))) {
944-
return new(tree.Extend)(elements, index);
945-
}
944+
return new(tree.Extend)(elements, index);
946945
},
947946

948947
//

lib/less/parser.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,8 @@ less.Parser = function Parser(env) {
525525
primary: function () {
526526
var node, root = [];
527527

528-
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
529-
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
530-
$(this.extend))
528+
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
529+
$(this.mixin.call) || $(this.comment) || $(this.directive))
531530
|| $(/^[\s\n]+/) || $(/^;+/)) {
532531
node && root.push(node);
533532
}
@@ -814,15 +813,15 @@ less.Parser = function Parser(env) {
814813
extend: function() {
815814
var elements = [], e, args, index = i;
816815

817-
if (input.charAt(i) !== '+') { return; }
816+
if (!$(/^&:extend\(/)) { return; }
818817

819-
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
820-
elements.push(new(tree.Element)(null, e.slice(2), i));
818+
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
819+
elements.push(new(tree.Element)(null, e, i));
821820
}
821+
822+
expect(/^\);/);
822823

823-
if (elements.length > 0 && ($(';') || peek('}'))) {
824-
return new(tree.Extend)(elements, index);
825-
}
824+
return new(tree.Extend)(elements, index);
826825
},
827826

828827
//

test/less/extend-clearfix.less

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
}
1010

1111
.foo {
12-
++.clearfix;
12+
&:extend(.clearfix);
1313
color: red;
1414
}
1515

1616
.bar {
17-
++.clearfix;
17+
&:extend(.clearfix);
1818
color: blue;
1919
}

test/less/extend-nest.less

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
}
1111

1212
.sidebar2 {
13-
++.sidebar;
13+
&:extend(.sidebar);
1414
background: blue;
1515
}
1616

1717
.type1 {
1818
.sidebar3 {
19-
++.sidebar;
19+
&:extend(.sidebar);
2020
background: green;
2121
}
2222
}

test/less/extend.less

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
display: none;
1111
}
1212
.badError {
13-
++.error;
13+
&:extend(.error);
1414
border-width: 3px;
1515
}
1616

@@ -19,12 +19,12 @@
1919
}
2020

2121
.ext1 .ext2 {
22-
++.foo;
22+
&:extend(.foo);
2323
}
2424

2525
.ext3,
2626
.ext4 {
27-
++.foo;
27+
&:extend(.foo);
2828
}
2929

3030
div.ext5,
@@ -33,5 +33,5 @@ div.ext5,
3333
}
3434

3535
.ext7 {
36-
++.ext5;
36+
&:extend(.ext5);
3737
}

0 commit comments

Comments
 (0)