/
Extend.cs
52 lines (44 loc) · 1.62 KB
/
Extend.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dotless.Core.Parser.Infrastructure;
using dotless.Core.Parser.Infrastructure.Nodes;
namespace dotless.Core.Parser.Tree
{
public class Extend : Node
{
public Extend(List<Selector> exact, List<Selector> partial)
{
Exact = exact;
Partial = partial;
}
public List<Selector> Exact{ get; set; }
public List<Selector> Partial { get; set; }
public override Node Evaluate(Env env)
{
var newExact = new List<Selector>();
foreach (var e in Exact)
{
var childContext = env.CreateChildEnv();
e.AppendCSS(childContext);
var selector = new Selector(new []{new Element(e.Elements.First().Combinator,childContext.Output.ToString().Trim())});
selector.IsReference = IsReference;
newExact.Add(selector);
}
var newPartial = new List<Selector>();
foreach (var e in Partial)
{
var childContext = env.CreateChildEnv();
e.AppendCSS(childContext);
var selector = new Selector(new[] { new Element(e.Elements.First().Combinator, childContext.Output.ToString().Trim()) });
selector.IsReference = IsReference;
newPartial.Add(selector);
}
return new Extend(newExact,newPartial) { IsReference = IsReference, Location = Location };
}
public override void AppendCSS(Env env)
{
}
}
}