[Pkg-javascript-commits] [less.js] 166/285: Fix issue #2221

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.0.0
in repository less.js.

commit 6d642139966381a30c40a6adface2b93f35a5e97
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Oct 11 18:51:09 2014 +0100

    Fix issue #2221
---
 lib/less/tree/combinator.js |  2 ++
 lib/less/tree/ruleset.js    | 11 ++++++++++-
 test/css/css-3.css          |  6 ++++++
 test/less/css-3.less        |  6 ++++++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/less/tree/combinator.js b/lib/less/tree/combinator.js
index 5342dc0..323522d 100644
--- a/lib/less/tree/combinator.js
+++ b/lib/less/tree/combinator.js
@@ -3,8 +3,10 @@ var Node = require("./node");
 var Combinator = function (value) {
     if (value === ' ') {
         this.value = ' ';
+        this.emptyOrWhitespace = true;
     } else {
         this.value = value ? value.trim() : "";
+        this.emptyOrWhitespace = this.value === "";
     }
 };
 Combinator.prototype = new Node();
diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js
index 74e8fd3..23c3ec4 100644
--- a/lib/less/tree/ruleset.js
+++ b/lib/less/tree/ruleset.js
@@ -522,8 +522,17 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
                         if (parentSel.length > 0) {
                             newJoinedSelectorEmpty = false;
 
+                            // /deep/ is a combinator that is valid without anything in front of it
+                            // so if the & does not have a combinator that is "" or " " then
+                            // and there is a combinator on the parent, then grab that.
+                            // this also allows + a { & .b { .a & { ... though not sure why you would want to do that
+                            var combinator = el.combinator,
+                                parentEl = parentSel[0].elements[0];
+                            if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
+                                combinator = parentEl.combinator;
+                            }
                             // join the elements so far with the first part of the parent
-                            newJoinedSelector.elements.push(new(Element)(el.combinator, parentSel[0].elements[0].value, el.index, el.currentFileInfo));
+                            newJoinedSelector.elements.push(new(Element)(combinator, parentEl.value, el.index, el.currentFileInfo));
                             newJoinedSelector.elements = newJoinedSelector.elements.concat(parentSel[0].elements.slice(1));
                         }
 
diff --git a/test/css/css-3.css b/test/css/css-3.css
index 7f13992..2ed044f 100644
--- a/test/css/css-3.css
+++ b/test/css/css-3.css
@@ -133,6 +133,12 @@ body ^^ .shadow {
 ::content .sel {
   type: shadow-dom;
 }
+ /deep/ b {
+  c: 'd';
+}
+ /deep/ b[e] {
+  f: 'g';
+}
 #issue2066 {
   background: url('/images/icon-team.svg') 0 0 / contain;
 }
diff --git a/test/less/css-3.less b/test/less/css-3.less
index 312653c..b35d0f4 100644
--- a/test/less/css-3.less
+++ b/test/less/css-3.less
@@ -134,6 +134,12 @@ body ^^ .shadow {
 ::content .sel {
   type: shadow-dom;
 }
+/deep/ b {
+ c: 'd';
+ &[e]{
+   f: 'g';
+ }
+}
 
 #issue2066 {
   background: url('/images/icon-team.svg') 0 0 / contain;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list