mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Add Sass like extend
This commit is contained in:
@@ -526,7 +526,8 @@ less.Parser = function Parser(env) {
|
||||
var node, root = [];
|
||||
|
||||
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
|
||||
$(this.mixin.call) || $(this.comment) || $(this.directive))
|
||||
$(this.mixin.call) || $(this.comment) || $(this.directive) ||
|
||||
$(this.extend))
|
||||
|| $(/^[\s\n]+/) || $(/^;+/)) {
|
||||
node && root.push(node);
|
||||
}
|
||||
@@ -803,6 +804,23 @@ less.Parser = function Parser(env) {
|
||||
if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
|
||||
return new(tree.Shorthand)(a, b);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// extend
|
||||
//
|
||||
extend: function() {
|
||||
var elements = [], e, c, args, index = i, s = input.charAt(i);
|
||||
|
||||
if (s !== '+') { return }
|
||||
|
||||
while (e = $(/^\+[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
|
||||
elements.push(new(tree.Element)(c, e.slice(1), i));
|
||||
}
|
||||
|
||||
if (elements.length > 0 && ($(';') || peek('}'))) {
|
||||
return new(tree.Extend)(elements, index);
|
||||
}
|
||||
|
||||
restore();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user