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

Method parse

www/js/_hyperscript.esm.js:4144–4180  ·  view source on GitHub ↗
(parser, root)

Source from the content-addressed store, hash-verified

4142 this._isComputed = urRoot.type === "computedStyleRef";
4143 }
4144 static parse(parser, root) {
4145 if (!parser.matchToken("of")) return;
4146 var newRoot = parser.requireElement("unaryExpression");
4147 var childOfUrRoot = null;
4148 var urRoot = root;
4149 while (urRoot.root) {
4150 childOfUrRoot = urRoot;
4151 urRoot = urRoot.root;
4152 }
4153 var validOfRoots = ["symbol", "attributeRef", "styleRef", "computedStyleRef"];
4154 if (!validOfRoots.includes(urRoot.type)) {
4155 parser.raiseError("Cannot take a property of a non-symbol: " + urRoot.type);
4156 }
4157 var attribute = urRoot.type === "attributeRef";
4158 var style = urRoot.type === "styleRef" || urRoot.type === "computedStyleRef";
4159 var attributeElt = attribute || style ? urRoot : null;
4160 var prop = urRoot.name;
4161 var propertyAccess = new _OfExpression(
4162 urRoot.token,
4163 // can be undefined for attributeRef
4164 newRoot,
4165 attributeElt,
4166 root,
4167 { root: newRoot },
4168 urRoot
4169 );
4170 if (urRoot.type === "attributeRef") {
4171 propertyAccess.attribute = urRoot;
4172 }
4173 if (childOfUrRoot) {
4174 childOfUrRoot.root = propertyAccess;
4175 childOfUrRoot.args = { root: propertyAccess };
4176 } else {
4177 root = propertyAccess;
4178 }
4179 return parser.parseElement("indirectExpression", root);
4180 }
4181 resolve(context, { root: rootVal }) {
4182 if (this._isAttribute) {
4183 return context.meta.runtime.resolveAttribute(rootVal, this._prop);

Callers

nothing calls this directly

Calls 4

matchTokenMethod · 0.45
requireElementMethod · 0.45
raiseErrorMethod · 0.45
parseElementMethod · 0.45

Tested by

no test coverage detected