MCPcopy
hub / github.com/less/less.js / variables

Method variables

packages/less/lib/less/tree/ruleset.js:356–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354 }
355
356 variables() {
357 if (!this._variables) {
358 this._variables = !this.rules ? {} : this.rules.reduce(function (/** @type {Object<string, Declaration>} */ hash, /** @type {Node} */ r) {
359 if (r instanceof Declaration && r.variable === true) {
360 hash[/** @type {string} */ (r.name)] = r;
361 }
362 // when evaluating variables in an import statement, imports have not been eval'd
363 // so we need to go inside import statements.
364 // guard against root being a string (in the case of inlined less)
365 if (r.type === 'Import' && /** @type {RuleNode} */ (r).root && /** @type {RuleNode & { root: Ruleset }} */ (r).root.variables) {
366 const vars = /** @type {RuleNode & { root: Ruleset }} */ (r).root.variables();
367 for (const name in vars) {
368 if (Object.prototype.hasOwnProperty.call(vars, name)) {
369 hash[name] = /** @type {Declaration} */ (/** @type {RuleNode & { root: Ruleset }} */ (r).root.variable(name));
370 }
371 }
372 }
373 return hash;
374 }, {});
375 }
376 return this._variables;
377 }
378
379 properties() {
380 if (!this._properties) {

Callers 2

variableMethod · 0.95
evaluateJavaScriptMethod · 0.80

Calls 2

callMethod · 0.80
variableMethod · 0.45

Tested by

no test coverage detected