container.js 841 B

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