aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs')
-rw-r--r--vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs103
1 files changed, 103 insertions, 0 deletions
diff --git a/vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs b/vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs
new file mode 100644
index 0000000..b2e0598
--- /dev/null
+++ b/vanilla/node_modules/css-tree/cjs/syntax/node/Atrule.cjs
@@ -0,0 +1,103 @@
+'use strict';
+
+const types = require('../../tokenizer/types.cjs');
+
+function consumeRaw() {
+ return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon, true);
+}
+
+function isDeclarationBlockAtrule() {
+ for (let offset = 1, type; type = this.lookupType(offset); offset++) {
+ if (type === types.RightCurlyBracket) {
+ return true;
+ }
+
+ if (type === types.LeftCurlyBracket ||
+ type === types.AtKeyword) {
+ return false;
+ }
+ }
+
+ return false;
+}
+
+
+const name = 'Atrule';
+const walkContext = 'atrule';
+const structure = {
+ name: String,
+ prelude: ['AtrulePrelude', 'Raw', null],
+ block: ['Block', null]
+};
+
+function parse(isDeclaration = false) {
+ const start = this.tokenStart;
+ let name;
+ let nameLowerCase;
+ let prelude = null;
+ let block = null;
+
+ this.eat(types.AtKeyword);
+
+ name = this.substrToCursor(start + 1);
+ nameLowerCase = name.toLowerCase();
+ this.skipSC();
+
+ // parse prelude
+ if (this.eof === false &&
+ this.tokenType !== types.LeftCurlyBracket &&
+ this.tokenType !== types.Semicolon) {
+ if (this.parseAtrulePrelude) {
+ prelude = this.parseWithFallback(this.AtrulePrelude.bind(this, name, isDeclaration), consumeRaw);
+ } else {
+ prelude = consumeRaw.call(this, this.tokenIndex);
+ }
+
+ this.skipSC();
+ }
+
+ switch (this.tokenType) {
+ case types.Semicolon:
+ this.next();
+ break;
+
+ case types.LeftCurlyBracket:
+ if (hasOwnProperty.call(this.atrule, nameLowerCase) &&
+ typeof this.atrule[nameLowerCase].block === 'function') {
+ block = this.atrule[nameLowerCase].block.call(this, isDeclaration);
+ } else {
+ // TODO: should consume block content as Raw?
+ block = this.Block(isDeclarationBlockAtrule.call(this));
+ }
+
+ break;
+ }
+
+ return {
+ type: 'Atrule',
+ loc: this.getLocation(start, this.tokenStart),
+ name,
+ prelude,
+ block
+ };
+}
+
+function generate(node) {
+ this.token(types.AtKeyword, '@' + node.name);
+
+ if (node.prelude !== null) {
+ this.node(node.prelude);
+ }
+
+ if (node.block) {
+ this.node(node.block);
+ } else {
+ this.token(types.Semicolon, ';');
+ }
+}
+
+exports.generate = generate;
+exports.name = name;
+exports.parse = parse;
+exports.structure = structure;
+exports.walkContext = walkContext;