diff --git a/lib/less/parser.js b/lib/less/parser.js index 1e04645d..9657eb4e 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -680,7 +680,7 @@ less.Parser = function Parser(env) { if (s !== '.' && s !== '#') { return } while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) { - elements.push(new(tree.Element)(c, e)); + elements.push(new(tree.Element)(c, e, i)); c = $('>'); } $('(') && (args = $(this.entities.arguments)) && $(')'); @@ -799,10 +799,10 @@ less.Parser = function Parser(env) { c = $(this.combinator); e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^(?:\d*\.)?\d+%/); - if (e) { return new(tree.Element)(c, e) } + if (e) { return new(tree.Element)(c, e, i) } if (c.value && c.value[0] === '&') { - return new(tree.Element)(c, null); + return new(tree.Element)(c, null, i); } }, diff --git a/lib/less/tree/element.js b/lib/less/tree/element.js index 27cf8228..a2f19bea 100644 --- a/lib/less/tree/element.js +++ b/lib/less/tree/element.js @@ -1,9 +1,10 @@ (function (tree) { -tree.Element = function (combinator, value) { +tree.Element = function (combinator, value, index) { this.combinator = combinator instanceof tree.Combinator ? combinator : new(tree.Combinator)(combinator); this.value = value ? value.trim() : ""; + this.index = index; }; tree.Element.prototype.toCSS = function (env) { return this.combinator.toCSS(env || {}) + this.value;