[Pkg-javascript-commits] [less.js] 11/25: Support for /deep/ selector. Fixes #2023

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


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

js pushed a commit to annotated tag v1.7.5
in repository less.js.

commit 74766691cc20b028892155ed2c879e9693540def
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Aug 14 16:35:13 2014 +0100

    Support for /deep/ selector. Fixes #2023
---
 lib/less/parser.js       | 12 +++++++++++-
 lib/less/tree/element.js | 28 ++++++----------------------
 test/css/css-3.css       |  6 ++++++
 test/less/css-3.less     |  7 +++++++
 4 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/lib/less/parser.js b/lib/less/parser.js
index 6abe053..0c925d1 100644
--- a/lib/less/parser.js
+++ b/lib/less/parser.js
@@ -1411,9 +1411,19 @@ less.Parser = function Parser(env) {
             combinator: function () {
                 var c = input.charAt(i);
 
+                if (c === '/') {
+                    save();
+                    var slashedCombinator = $re(/\/[a-z]+\//i);
+                    if (slashedCombinator) {
+                        forget();
+                        return new(tree.Combinator)(slashedCombinator);
+                    }
+                    restore();
+                }
+
                 if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
                     i++;
-                    if (input.charAt(i) === '^') {
+                    if (c === '^' && input.charAt(i) === '^') {
                         c = '^^';
                         i++;
                     }
diff --git a/lib/less/tree/element.js b/lib/less/tree/element.js
index 3869f6c..055cce8 100644
--- a/lib/less/tree/element.js
+++ b/lib/less/tree/element.js
@@ -77,30 +77,14 @@ tree.Combinator = function (value) {
 };
 tree.Combinator.prototype = {
     type: "Combinator",
-    _outputMap: {
-        ''  : '',
-        ' ' : ' ',
-        ':' : ' :',
-        '+' : ' + ',
-        '~' : ' ~ ',
-        '>' : ' > ',
-        '|' : '|',
-        '^' : ' ^ ',
-        '^^' : ' ^^ '
-    },
-    _outputMapCompressed: {
-        ''  : '',
-        ' ' : ' ',
-        ':' : ' :',
-        '+' : '+',
-        '~' : '~',
-        '>' : '>',
-        '|' : '|',
-        '^' : '^',
-        '^^' : '^^'
+    _noSpaceCombinators: {
+        '': true,
+        ' ': true,
+        '|': true
     },
     genCSS: function (env, output) {
-        output.add((env.compress ? this._outputMapCompressed : this._outputMap)[this.value]);
+        var spaceOrEmpty = (env.compress || this._noSpaceCombinators[this.value]) ? '' : ' ';
+        output.add(spaceOrEmpty + this.value + spaceOrEmpty);
     },
     toCSS: tree.toCSS
 };
diff --git a/test/css/css-3.css b/test/css/css-3.css
index 4dd7243..c6f4c62 100644
--- a/test/css/css-3.css
+++ b/test/css/css-3.css
@@ -127,6 +127,12 @@ h1 {
 body ^^ .shadow {
   display: done;
 }
+:host(.sel .a),
+:host-context(.sel .b),
+.sel /deep/ .b,
+::content .sel {
+  type: shadow-dom;
+}
 #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 c054dc4..312653c 100644
--- a/test/less/css-3.less
+++ b/test/less/css-3.less
@@ -128,6 +128,13 @@ body ^^ .shadow {
   display: done;
 }
 
+:host(.sel .a),
+:host-context(.sel .b),
+.sel /deep/ .b,
+::content .sel {
+  type: shadow-dom;
+}
+
 #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