Change extend format to :extend(.class); - part 1 - support for stand-alone &:extend(.class);

This commit is contained in:
Luke Page
2012-11-05 21:01:41 +00:00
parent d9f929a063
commit c1efcf4e57
7 changed files with 34 additions and 37 deletions

17
dist/less-1.4.0.js vendored
View File

@@ -654,9 +654,8 @@ less.Parser = function Parser(env) {
primary: function () {
var node, root = [];
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
$(this.extend))
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive))
|| $(/^[\s\n]+/) || $(/^;+/)) {
node && root.push(node);
}
@@ -942,15 +941,15 @@ less.Parser = function Parser(env) {
extend: function() {
var elements = [], e, args, index = i;
if (input.charAt(i) !== '+') { return; }
if (!$(/^&:extend\(/)) { return; }
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e.slice(2), i));
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e, i));
}
expect(/^\);/);
if (elements.length > 0 && ($(';') || peek('}'))) {
return new(tree.Extend)(elements, index);
}
return new(tree.Extend)(elements, index);
},
//

File diff suppressed because one or more lines are too long

View File

@@ -646,9 +646,8 @@ less.Parser = function Parser(env) {
primary: function () {
var node, root = [];
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
$(this.extend))
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive))
|| $(/^[\s\n]+/) || $(/^;+/)) {
node && root.push(node);
}
@@ -934,15 +933,15 @@ less.Parser = function Parser(env) {
extend: function() {
var elements = [], e, args, index = i;
if (input.charAt(i) !== '+') { return; }
if (!$(/^&:extend\(/)) { return; }
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e.slice(2), i));
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e, i));
}
expect(/^\);/);
if (elements.length > 0 && ($(';') || peek('}'))) {
return new(tree.Extend)(elements, index);
}
return new(tree.Extend)(elements, index);
},
//

View File

@@ -525,9 +525,8 @@ less.Parser = function Parser(env) {
primary: function () {
var node, root = [];
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
$(this.extend))
while ((node = $(this.extend) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive))
|| $(/^[\s\n]+/) || $(/^;+/)) {
node && root.push(node);
}
@@ -814,15 +813,15 @@ less.Parser = function Parser(env) {
extend: function() {
var elements = [], e, args, index = i;
if (input.charAt(i) !== '+') { return; }
if (!$(/^&:extend\(/)) { return; }
while (e = $(/^\+\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e.slice(2), i));
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(null, e, i));
}
expect(/^\);/);
if (elements.length > 0 && ($(';') || peek('}'))) {
return new(tree.Extend)(elements, index);
}
return new(tree.Extend)(elements, index);
},
//

View File

@@ -9,11 +9,11 @@
}
.foo {
++.clearfix;
&:extend(.clearfix);
color: red;
}
.bar {
++.clearfix;
&:extend(.clearfix);
color: blue;
}

View File

@@ -10,13 +10,13 @@
}
.sidebar2 {
++.sidebar;
&:extend(.sidebar);
background: blue;
}
.type1 {
.sidebar3 {
++.sidebar;
&:extend(.sidebar);
background: green;
}
}

View File

@@ -10,7 +10,7 @@
display: none;
}
.badError {
++.error;
&:extend(.error);
border-width: 3px;
}
@@ -19,12 +19,12 @@
}
.ext1 .ext2 {
++.foo;
&:extend(.foo);
}
.ext3,
.ext4 {
++.foo;
&:extend(.foo);
}
div.ext5,
@@ -33,5 +33,5 @@ div.ext5,
}
.ext7 {
++.ext5;
&:extend(.ext5);
}