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

Method parse

www/js/_hyperscript-max.js:4145–4181  ·  view source on GitHub ↗
(parser, root)

Source from the content-addressed store, hash-verified

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