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

Method parse

src/parsetree/commands/basic.js:792–827  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

790 }
791
792 static parse(parser) {
793 if (!parser.matchToken("scroll")) return;
794
795 // scroll to ... form
796 if (parser.matchToken("to")) {
797 var scroll = _parseScrollModifiers(parser);
798 return new ScrollCommand(scroll.target, scroll.offset, scroll.plusOrMinus, scroll.scrollOptions, scroll.container);
799 }
800
801 // scroll [<target>] [up|down|left|right] by <amount>px [smoothly|instantly]
802 var direction = parser.matchAnyToken("up", "down", "left", "right");
803 var target;
804
805 if (!direction && parser.currentToken().value !== "by") {
806 target = parser.requireElement("unaryExpression");
807 direction = parser.matchAnyToken("up", "down", "left", "right");
808 }
809
810 parser.requireToken("by");
811
812 parser.pushFollow("px");
813 var offset;
814 try {
815 offset = parser.requireElement("expression");
816 } finally {
817 parser.popFollow();
818 }
819 parser.matchToken("px");
820
821 var behavior = _parseSmoothness(parser);
822 var scrollOptions = {};
823 if (behavior) scrollOptions.behavior = behavior;
824
825 var byMode = { direction: direction ? direction.value : "down" };
826 return new ScrollCommand(target, offset, null, scrollOptions, null, byMode);
827 }
828
829 resolve(ctx, { target, offset, container }) {
830 if (this.byMode) {

Callers

nothing calls this directly

Calls 9

_parseScrollModifiersFunction · 0.70
_parseSmoothnessFunction · 0.70
matchTokenMethod · 0.45
matchAnyTokenMethod · 0.45
currentTokenMethod · 0.45
requireElementMethod · 0.45
requireTokenMethod · 0.45
pushFollowMethod · 0.45
popFollowMethod · 0.45

Tested by

no test coverage detected