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

Method parse

tools/common/_hyperscript.iife.js:8857–9035  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

8855 }
8856 }
8857 static parse(parser) {
8858 if (!parser.matchToken("on")) return;
8859 var every = false;
8860 var first = false;
8861 if (parser.matchToken("every")) {
8862 every = true;
8863 } else if (parser.matchToken("first")) {
8864 first = true;
8865 }
8866 var events = [];
8867 var displayName = null;
8868 do {
8869 var on = parser.requireElement("eventName", "Expected event name");
8870 var eventName = on.evalStatically();
8871 if (displayName) {
8872 displayName = displayName + " or " + eventName;
8873 } else {
8874 displayName = "on " + eventName;
8875 }
8876 var args = ParseElement.parseEventArgs(parser);
8877 var filter = null;
8878 if (parser.matchOpToken("[")) {
8879 filter = parser.requireElement("expression");
8880 parser.requireOpToken("]");
8881 }
8882 var startCount, endCount, unbounded;
8883 if (first) {
8884 startCount = 1;
8885 } else if (parser.currentToken().type === "NUMBER") {
8886 var startCountToken = parser.consumeToken();
8887 if (!startCountToken.value) return;
8888 startCount = parseInt(startCountToken.value);
8889 if (parser.matchToken("to")) {
8890 var endCountToken = parser.consumeToken();
8891 if (!endCountToken.value) return;
8892 endCount = parseInt(endCountToken.value);
8893 } else if (parser.matchToken("and")) {
8894 unbounded = true;
8895 parser.requireToken("on");
8896 }
8897 }
8898 var intersectionSpec, mutationSpec, resizeSpec;
8899 if (eventName === "resize") {
8900 resizeSpec = true;
8901 } else if (eventName === "intersection") {
8902 intersectionSpec = {};
8903 if (parser.matchToken("with")) {
8904 intersectionSpec["with"] = parser.requireElement("expression").evalStatically();
8905 }
8906 if (parser.matchToken("having")) {
8907 do {
8908 if (parser.matchToken("margin")) {
8909 intersectionSpec["rootMargin"] = parser.requireElement("stringLike").evalStatically();
8910 } else if (parser.matchToken("threshold")) {
8911 intersectionSpec["threshold"] = parser.requireElement("expression").evalStatically();
8912 } else {
8913 parser.raiseError("Unknown intersection config specification");
8914 }

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