MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript.esm.js:6388–6417  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

6386 this.scrollOptions = scrollOptions;
6387 }
6388 static parse(parser) {
6389 if (!parser.matchToken("go")) return;
6390 if (parser.matchToken("back")) {
6391 return new _GoCommand(null, null, true);
6392 }
6393 parser.matchToken("to");
6394 if (parser.matchToken("url")) {
6395 var target = parser.requireElement("stringLike");
6396 var newWindow = false;
6397 if (parser.matchToken("in")) {
6398 parser.requireToken("new");
6399 parser.requireToken("window");
6400 newWindow = true;
6401 }
6402 return new _GoCommand(target, null, false, newWindow);
6403 }
6404 var cur = parser.currentToken();
6405 if (cur.value === "the" || cur.value === "top" || cur.value === "middle" || cur.value === "bottom" || cur.value === "left" || cur.value === "center" || cur.value === "right") {
6406 var scroll = _parseScrollModifiers(parser);
6407 return new _GoCommand(scroll.target, scroll.offset, false, false, scroll.plusOrMinus, scroll.scrollOptions);
6408 }
6409 var target = parser.parseURLOrExpression();
6410 var newWindow = false;
6411 if (parser.matchToken("in")) {
6412 parser.requireToken("new");
6413 parser.requireToken("window");
6414 newWindow = true;
6415 }
6416 return new _GoCommand(target, null, false, newWindow);
6417 }
6418 resolve(ctx, { target: to, offset }) {
6419 if (this.back) {
6420 window.history.back();

Callers

nothing calls this directly

Calls 6

_parseScrollModifiersFunction · 0.70
matchTokenMethod · 0.45
requireElementMethod · 0.45
requireTokenMethod · 0.45
currentTokenMethod · 0.45
parseURLOrExpressionMethod · 0.45

Tested by

no test coverage detected