You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
569 B

2 years ago
  1. 'use strict'
  2. let Container = require('./container')
  3. let list = require('./list')
  4. class Rule extends Container {
  5. constructor(defaults) {
  6. super(defaults)
  7. this.type = 'rule'
  8. if (!this.nodes) this.nodes = []
  9. }
  10. get selectors() {
  11. return list.comma(this.selector)
  12. }
  13. set selectors(values) {
  14. let match = this.selector ? this.selector.match(/,\s*/) : null
  15. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
  16. this.selector = values.join(sep)
  17. }
  18. }
  19. module.exports = Rule
  20. Rule.default = Rule
  21. Container.registerRule(Rule)