efront 4.1.1 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -431,11 +431,15 @@ function evalscoped(scoped, base = '') {
431
431
  var vlist = [vars];
432
432
  var mlist = [macros];
433
433
  var clist = [smaps];
434
+ var calcvars = function (v) {
435
+ return v.replace(/(^|\s|[\]\)\(\[\-\+\*\/,;])(?:var\s*\(([\s\S]*?)\)|(--\S+|@[^\s\{\}\(\)\[\]\:\+\*\/,;\!\>\$\=\&\%\#\@'"`\?\.\/\|~#]+|@\{[^\}@]*\}))/g, function (m, q, a, b) {
436
+ return q + getFromScopeList(b || a.trim(), vlist, m.slice(q.length));
437
+ });
438
+ };
434
439
  var initvars = function (vars) {
435
440
  for (var k in vars) {
436
441
  var v = vars[k];
437
- v = getFromScopeList(v, vlist);
438
- vars[k] = v;
442
+ vars[k] = replace_punc(calcvars(v));
439
443
  }
440
444
  };
441
445
  initvars(vars);
@@ -453,11 +457,6 @@ function evalscoped(scoped, base = '') {
453
457
  base = temp;
454
458
  return res;
455
459
  };
456
- var calcvars = function (v) {
457
- return v.replace(/(^|\s|[\]\)\(\[\-\+\*\/,;])(?:var\s*\(([\s\S]*?)\)|(--\S+|@[^\s\{\(\:\+\*\/,;\!\[\>\$\=\&\%\#\@\+'"`\?\.\/\|~]+|@\{[^\}@]*\}))/g, function (m, q, a, b) {
458
- return q + getFromScopeList(b || a.trim(), vlist, m.slice(q.length));
459
- });
460
- };
461
460
  var evalproc = function (k, retnoparam) {
462
461
  var match = (retnoparam !== false ? /^([^\(\)\s,;:]*)(?:\s*\(([\s\S]*)\))$/ : /^([^\(\)\s,;:]+)(?:\s*\(([\s\S]*)\))?$/).exec(k);
463
462
  if (!match) return calcvars(k);
@@ -536,6 +535,7 @@ function evalscoped(scoped, base = '') {
536
535
  if (base && !p.rooted) p.base = fixBase(base, k);
537
536
  else p.base = presets.test(k) ? `@{${k}}` : k;
538
537
  if (p.vars) vlist.push(p.vars);
538
+ initvars(p.vars);
539
539
  var value = evalthis(p);
540
540
  if (p.vars) vlist.pop();
541
541
  if (value.rest.length) rest = rest.concat(value.rest);
@@ -65,4 +65,6 @@ assert(素馨(`&{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
65
65
  assert(素馨(`:root>a{&:not(a):not(b){c:d}}`, '.abc-'), `.abc->a:not(a):not(b){c:d;}`);
66
66
  assert(素馨(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'), `a>.abc-:not(a):not(b){c:d;}`);
67
67
 
68
- assert(素馨(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
68
+ assert(素馨(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
69
+ assert(素馨(`@a:1px;@margin-x:@a+10px; a{m:-@margin-x}`), `a{m:-11px;}`);
70
+ assert(素馨(`a{@a:1px;@margin-x:@a+10px;m:-@margin-x}`), `a{m:-11px;}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {