MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript.js:9307–9485  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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

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