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

Method parse

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

Source from the content-addressed store, hash-verified

9303 }
9304 }
9305 static parse(parser) {
9306 if (!parser.matchToken("on")) return;
9307 var every = false;
9308 var first = false;
9309 if (parser.matchToken("every")) {
9310 every = true;
9311 } else if (parser.matchToken("first")) {
9312 first = true;
9313 }
9314 var events = [];
9315 var displayName = null;
9316 do {
9317 var on = parser.requireElement("eventName", "Expected event name");
9318 var eventName = on.evalStatically();
9319 if (displayName) {
9320 displayName = displayName + " or " + eventName;
9321 } else {
9322 displayName = "on " + eventName;
9323 }
9324 var args = ParseElement.parseEventArgs(parser);
9325 var filter = null;
9326 if (parser.matchOpToken("[")) {
9327 filter = parser.requireElement("expression");
9328 parser.requireOpToken("]");
9329 }
9330 var startCount, endCount, unbounded;
9331 if (first) {
9332 startCount = 1;
9333 } else if (parser.currentToken().type === "NUMBER") {
9334 var startCountToken = parser.consumeToken();
9335 if (!startCountToken.value) return;
9336 startCount = parseInt(startCountToken.value);
9337 if (parser.matchToken("to")) {
9338 var endCountToken = parser.consumeToken();
9339 if (!endCountToken.value) return;
9340 endCount = parseInt(endCountToken.value);
9341 } else if (parser.matchToken("and")) {
9342 unbounded = true;
9343 parser.requireToken("on");
9344 }
9345 }
9346 var intersectionSpec, mutationSpec, resizeSpec;
9347 if (eventName === "resize") {
9348 resizeSpec = true;
9349 } else if (eventName === "intersection") {
9350 intersectionSpec = {};
9351 if (parser.matchToken("with")) {
9352 intersectionSpec["with"] = parser.requireElement("expression").evalStatically();
9353 }
9354 if (parser.matchToken("having")) {
9355 do {
9356 if (parser.matchToken("margin")) {
9357 intersectionSpec["rootMargin"] = parser.requireElement("stringLike").evalStatically();
9358 } else if (parser.matchToken("threshold")) {
9359 intersectionSpec["threshold"] = parser.requireElement("expression").evalStatically();
9360 } else {
9361 parser.raiseError("Unknown intersection config specification");
9362 }

Callers

nothing calls this directly

Calls 15

matchTokenMethod · 0.45
requireElementMethod · 0.45
evalStaticallyMethod · 0.45
parseEventArgsMethod · 0.45
matchOpTokenMethod · 0.45
requireOpTokenMethod · 0.45
currentTokenMethod · 0.45
consumeTokenMethod · 0.45
requireTokenMethod · 0.45
raiseErrorMethod · 0.45
pushFollowMethod · 0.45
popFollowMethod · 0.45

Tested by

no test coverage detected