mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
extend options, algin with decided syntax
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
//
|
||||
// LESS - Leaner CSS v@VERSION
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2009-2013, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
/*
|
||||
* LESS - Leaner CSS v@VERSION
|
||||
* http://lesscss.org
|
||||
*
|
||||
* Copyright (c) 2009-2013, Alexis Sellier
|
||||
* Licensed under the Apache 2.0 License.
|
||||
*
|
||||
* @licence
|
||||
*/
|
||||
|
||||
37
dist/less-1.4.0-alpha.js
vendored
37
dist/less-1.4.0-alpha.js
vendored
@@ -1,10 +1,12 @@
|
||||
//
|
||||
// LESS - Leaner CSS v1.4.0
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2009-2013, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
/*
|
||||
* LESS - Leaner CSS v1.4.0
|
||||
* http://lesscss.org
|
||||
*
|
||||
* Copyright (c) 2009-2013, Alexis Sellier
|
||||
* Licensed under the Apache 2.0 License.
|
||||
*
|
||||
* @licence
|
||||
*/
|
||||
(function (window, undefined) {
|
||||
//
|
||||
// Stub out `require` in the browser
|
||||
@@ -923,21 +925,31 @@ less.Parser = function Parser(env) {
|
||||
// extend syntax - used to extend selectors
|
||||
//
|
||||
extend: function(isRule) {
|
||||
var elements = [], e, args, index = i;
|
||||
var elements = [], e, args, index = i, option;
|
||||
|
||||
if (!$(isRule ? /^&:extend\(/ : /^:extend\(/)) { return; }
|
||||
|
||||
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
|
||||
while (true) {
|
||||
option = $(/^(any|deep|all)(?=\s*\))/);
|
||||
if (option) { break; }
|
||||
e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/);
|
||||
if (!e) { break; }
|
||||
elements.push(new(tree.Element)(null, e, i));
|
||||
}
|
||||
|
||||
|
||||
expect(/^\)/);
|
||||
|
||||
option = option && option[1];
|
||||
|
||||
if (option != "all") {
|
||||
error(":extend only supports the all option at the moment, please specify it after your selector, e.g. :extend(.a all)");
|
||||
}
|
||||
|
||||
if (isRule) {
|
||||
expect(/^;/);
|
||||
}
|
||||
|
||||
return new(tree.Extend)(elements, index);
|
||||
return new(tree.Extend)(elements, option, index);
|
||||
},
|
||||
|
||||
//
|
||||
@@ -3087,8 +3099,9 @@ tree.Expression.prototype = {
|
||||
})(require('../tree'));
|
||||
(function (tree) {
|
||||
|
||||
tree.Extend = function Extend(elements, index) {
|
||||
tree.Extend = function Extend(elements, option, index) {
|
||||
this.selector = new(tree.Selector)(elements);
|
||||
this.option = option;
|
||||
this.index = index;
|
||||
};
|
||||
|
||||
|
||||
13
dist/less-1.4.0-alpha.min.js
vendored
13
dist/less-1.4.0-alpha.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -788,21 +788,31 @@ less.Parser = function Parser(env) {
|
||||
// extend syntax - used to extend selectors
|
||||
//
|
||||
extend: function(isRule) {
|
||||
var elements = [], e, args, index = i;
|
||||
var elements = [], e, args, index = i, option;
|
||||
|
||||
if (!$(isRule ? /^&:extend\(/ : /^:extend\(/)) { return; }
|
||||
|
||||
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
|
||||
while (true) {
|
||||
option = $(/^(any|deep|all)(?=\s*\))/);
|
||||
if (option) { break; }
|
||||
e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/);
|
||||
if (!e) { break; }
|
||||
elements.push(new(tree.Element)(null, e, i));
|
||||
}
|
||||
|
||||
|
||||
expect(/^\)/);
|
||||
|
||||
option = option && option[1];
|
||||
|
||||
if (option != "all") {
|
||||
error(":extend only supports the all option at the moment, please specify it after your selector, e.g. :extend(.a all)");
|
||||
}
|
||||
|
||||
if (isRule) {
|
||||
expect(/^;/);
|
||||
}
|
||||
|
||||
return new(tree.Extend)(elements, index);
|
||||
return new(tree.Extend)(elements, option, index);
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Extend = function Extend(elements, index) {
|
||||
tree.Extend = function Extend(elements, option, index) {
|
||||
this.selector = new(tree.Selector)(elements);
|
||||
this.option = option;
|
||||
this.index = index;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
}
|
||||
|
||||
.foo {
|
||||
&:extend(.clearfix);
|
||||
&:extend(.clearfix all);
|
||||
color: red;
|
||||
}
|
||||
|
||||
.bar {
|
||||
&:extend(.clearfix);
|
||||
&:extend(.clearfix all);
|
||||
color: blue;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
}
|
||||
|
||||
.sidebar2 {
|
||||
&:extend(.sidebar);
|
||||
&:extend(.sidebar all);
|
||||
background: blue;
|
||||
}
|
||||
|
||||
.type1 {
|
||||
.sidebar3 {
|
||||
&:extend(.sidebar);
|
||||
&:extend(.sidebar all);
|
||||
background: green;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
.intrusion .error {
|
||||
display: none;
|
||||
}
|
||||
.badError:extend(.error) {
|
||||
.badError:extend(.error all) {
|
||||
border-width: 3px;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
}
|
||||
|
||||
.ext1 .ext2
|
||||
:extend(.foo) {
|
||||
:extend(.foo all) {
|
||||
}
|
||||
|
||||
.ext3:extend(.foo),
|
||||
.ext4:extend(.foo) {
|
||||
.ext3:extend(.foo all),
|
||||
.ext4:extend(.foo all) {
|
||||
}
|
||||
|
||||
div.ext5,
|
||||
@@ -31,20 +31,20 @@ div.ext5,
|
||||
}
|
||||
|
||||
.should-not-exist-in-output,
|
||||
.ext7:extend(.ext5) {
|
||||
.ext7:extend(.ext5 all) {
|
||||
}
|
||||
|
||||
.ext {
|
||||
test: 1;
|
||||
}
|
||||
// same as
|
||||
// .a .c:extend(.ext)
|
||||
// .b .c:extend(.ext)
|
||||
// .a .c:extend(.ext all)
|
||||
// .b .c:extend(.ext all)
|
||||
// .a .c .d
|
||||
// .b .c .d
|
||||
.a, .b {
|
||||
test: 2;
|
||||
.c:extend(.ext) {
|
||||
.c:extend(.ext all) {
|
||||
test: 3;
|
||||
.d {
|
||||
test: 4;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
display: none;
|
||||
}
|
||||
.badError {
|
||||
&:extend(.error);
|
||||
&:extend(.error all);
|
||||
border-width: 3px;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
}
|
||||
|
||||
.ext1 .ext2 {
|
||||
&:extend(.foo);
|
||||
&:extend(.foo all);
|
||||
}
|
||||
|
||||
.ext3,
|
||||
.ext4 {
|
||||
&:extend(.foo);
|
||||
&:extend(.foo all);
|
||||
}
|
||||
|
||||
div.ext5,
|
||||
@@ -33,5 +33,5 @@ div.ext5,
|
||||
}
|
||||
|
||||
.ext7 {
|
||||
&:extend(.ext5);
|
||||
&:extend(.ext5 all);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user