A stylesheet language written in TypeScript that compiles to CSS
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425
  1. import Token from '../token';
  2. export class Selector {
  3. public name: Token;
  4. public parents: Selector[];
  5. public constructor(name: Token, parents: Selector[] = []) {
  6. this.name = name;
  7. this.parents = parents;
  8. }
  9. public getLineages(): string[] {
  10. if (this.parents.length === 0) return [this.name.value];
  11. return Array.prototype.concat(
  12. ...this.parents.map((parent) => {
  13. return parent.getLineages().map((lineage) => {
  14. if (this.name.value.match(/&/)) {
  15. return this.name.value.replace('&', lineage);
  16. }
  17. return lineage + ' ' + this.name.value;
  18. });
  19. })
  20. );
  21. }
  22. }