1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var tslib_1 = require("tslib");
|
---|
4 | var node_1 = tslib_1.__importDefault(require("./node"));
|
---|
5 | var declaration_1 = tslib_1.__importDefault(require("./declaration"));
|
---|
6 | var Property = function (name, index, currentFileInfo) {
|
---|
7 | this.name = name;
|
---|
8 | this._index = index;
|
---|
9 | this._fileInfo = currentFileInfo;
|
---|
10 | };
|
---|
11 | Property.prototype = Object.assign(new node_1.default(), {
|
---|
12 | type: 'Property',
|
---|
13 | eval: function (context) {
|
---|
14 | var property;
|
---|
15 | var name = this.name;
|
---|
16 | // TODO: shorten this reference
|
---|
17 | var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;
|
---|
18 | if (this.evaluating) {
|
---|
19 | throw { type: 'Name', message: "Recursive property reference for " + name, filename: this.fileInfo().filename,
|
---|
20 | index: this.getIndex() };
|
---|
21 | }
|
---|
22 | this.evaluating = true;
|
---|
23 | property = this.find(context.frames, function (frame) {
|
---|
24 | var v;
|
---|
25 | var vArr = frame.property(name);
|
---|
26 | if (vArr) {
|
---|
27 | for (var i = 0; i < vArr.length; i++) {
|
---|
28 | v = vArr[i];
|
---|
29 | vArr[i] = new declaration_1.default(v.name, v.value, v.important, v.merge, v.index, v.currentFileInfo, v.inline, v.variable);
|
---|
30 | }
|
---|
31 | mergeRules(vArr);
|
---|
32 | v = vArr[vArr.length - 1];
|
---|
33 | if (v.important) {
|
---|
34 | var importantScope = context.importantScope[context.importantScope.length - 1];
|
---|
35 | importantScope.important = v.important;
|
---|
36 | }
|
---|
37 | v = v.value.eval(context);
|
---|
38 | return v;
|
---|
39 | }
|
---|
40 | });
|
---|
41 | if (property) {
|
---|
42 | this.evaluating = false;
|
---|
43 | return property;
|
---|
44 | }
|
---|
45 | else {
|
---|
46 | throw { type: 'Name', message: "Property '" + name + "' is undefined", filename: this.currentFileInfo.filename,
|
---|
47 | index: this.index };
|
---|
48 | }
|
---|
49 | },
|
---|
50 | find: function (obj, fun) {
|
---|
51 | for (var i = 0, r = void 0; i < obj.length; i++) {
|
---|
52 | r = fun.call(obj, obj[i]);
|
---|
53 | if (r) {
|
---|
54 | return r;
|
---|
55 | }
|
---|
56 | }
|
---|
57 | return null;
|
---|
58 | }
|
---|
59 | });
|
---|
60 | exports.default = Property;
|
---|
61 | //# sourceMappingURL=property.js.map |
---|