diff --git a/lib/less/extend-visitor.js b/lib/less/extend-visitor.js index 01e3b988..6cbdbcb5 100644 --- a/lib/less/extend-visitor.js +++ b/lib/less/extend-visitor.js @@ -157,7 +157,7 @@ for(k = 0; k < selectorPath.length; k++) { selector = selectorPath[k]; for(i = 0; i < selector.elements.length; i++) { - if (extend.any || (k == 0 && i == 0)) { + if (extend.allowBefore || (k == 0 && i == 0)) { potentialMatches.push({pathIndex: k, index: i, matched: 0, initialCombinator: selector.elements[i].combinator}); } @@ -178,7 +178,7 @@ if (potentialMatch) { potentialMatch.finished = potentialMatch.matched === extend.selector.elements.length; if (potentialMatch.finished && - (!extend.deep && (i+1 < selector.elements.length || + (!extend.allowAfter && (i+1 < selector.elements.length || k+1 < selectorPath.length))) { potentialMatch = null; } diff --git a/lib/less/parser.js b/lib/less/parser.js index 9b42168a..665bdd7c 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -794,7 +794,7 @@ less.Parser = function Parser(env) { if (!$(isRule ? /^&:extend\(/ : /^:extend\(/)) { return; } while (true) { - option = $(/^(any|deep|all)(?=\s*\))/); + option = $(/^(all)(?=\s*\))/); if (option) { break; } e = $(this.element); if (!e) { break; } diff --git a/lib/less/tree/extend.js b/lib/less/tree/extend.js index 1302f807..18f60f4e 100644 --- a/lib/less/tree/extend.js +++ b/lib/less/tree/extend.js @@ -7,20 +7,12 @@ tree.Extend = function Extend(selector, option, index) { switch(option) { case "all": - this.deep = true; - this.any = true; - break; - case "deep": - this.deep = true; - this.any = false; - break; - case "any": - this.deep = false; - this.any = true; + this.allowBefore = true; + this.allowAfter = true; break; default: - this.deep = false; - this.any = false; + this.allowBefore = false; + this.allowAfter = false; break; } }; diff --git a/test/css/extend-deep.css b/test/css/extend-deep.css deleted file mode 100644 index 5225a957..00000000 --- a/test/css/extend-deep.css +++ /dev/null @@ -1,49 +0,0 @@ -.replace.replace .replace, -.c.replace + .replace .replace, -.replace.replace .c, -.c.replace + .replace .c, -.rep_ace, -.effected.replace + .replace .replace, -.effected.replace + .replace .c { - prop: copy-paste-replace; -} -.replace.replace .replace .d, -.c.replace + .replace .replace .d, -.replace.replace .c .d, -.c.replace + .replace .c .d, -.rep_ace .d, -.effected.replace + .replace .replace .d, -.effected.replace + .replace .c .d { - prop: deep; -} -.a .b .c, -.effected .b .c { - prop: is_effected; -} -.a, -.effected { - prop: is_effected; -} -.a .b, -.effected .b { - prop: is_effected; -} -.a .b.c, -.effected .b.c { - prop: is_effected; -} -.b .a { - prop: not_effected; -} -.a:hover, -.effected:hover { - hover: is_effected; -} -.e.e, -.dbl { - prop: extend-double; -} -.e.e:hover, -.dbl:hover { - hover: up; -} diff --git a/test/less/extend-deep.less b/test/less/extend-deep.less deleted file mode 100644 index 8569daf1..00000000 --- a/test/less/extend-deep.less +++ /dev/null @@ -1,52 +0,0 @@ -.replace.replace, -.c.replace + .replace { - .replace, - .c { - prop: copy-paste-replace; - .d { - prop: deep; - } - } -} -.rep_ace:extend(.replace.replace .replace deep) {} - -.a .b .c { - prop: is_effected; -} - -.a { - prop: is_effected; - .b { - prop: is_effected; - } - .b.c { - prop: is_effected; - } -} - -.b { - .a { - prop: not_effected; - } -} - -.a { - &:hover { - hover: is_effected; - } -} - -.effected { - &:extend(.a deep); - &:extend(.c deep); -} - -.e { - && { - prop: extend-double; - &:hover { - hover: up; - } - } -} -.dbl:extend(.e.e deep) {} \ No newline at end of file