mirror of
https://github.com/less/less.js.git
synced 2026-02-04 03:55:10 -05:00
Merge pull request #450 from fat/index-on-element-root
store index on selector element objects for line number inference
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user