container.cjs 896 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const types = require('../../tokenizer/types.cjs');
  3. // https://drafts.csswg.org/css-contain-3/#container-rule
  4. // The keywords `none`, `and`, `not`, and `or` are excluded from the <custom-ident> above.
  5. const nonContainerNameKeywords = new Set(['none', 'and', 'not', 'or']);
  6. const container = {
  7. parse: {
  8. prelude() {
  9. const children = this.createList();
  10. if (this.tokenType === types.Ident) {
  11. const name = this.substring(this.tokenStart, this.tokenEnd);
  12. if (!nonContainerNameKeywords.has(name.toLowerCase())) {
  13. children.push(this.Identifier());
  14. }
  15. }
  16. children.push(this.Condition('container'));
  17. return children;
  18. },
  19. block(nested = false) {
  20. return this.Block(nested);
  21. }
  22. }
  23. };
  24. module.exports = container;