MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / #resolveInherited

Method #resolveInherited

src/core/runtime/runtime.js:365–395  ·  view source on GitHub ↗
(str, context, startElement)

Source from the content-addressed store, hash-verified

363 }
364
365 #resolveInherited(str, context, startElement) {
366 var elt = startElement || (context.meta && context.meta.owner);
367 while (elt) {
368 var internalData = elt._hyperscript;
369 if (internalData && internalData.elementScope && str in internalData.elementScope) {
370 return { value: internalData.elementScope[str], element: elt };
371 }
372 // Check dom-scope attribute for scope control
373 var domScope = elt.getAttribute && elt.getAttribute('dom-scope');
374 if (domScope) {
375 if (domScope === 'isolated') {
376 return { value: undefined, element: null };
377 }
378 // "closest <selector>" - jump to matching ancestor
379 var match = domScope.match(/^closest\s+(.+)/);
380 if (match) {
381 elt = elt.parentElement && elt.parentElement.closest(match[1]);
382 continue;
383 }
384 // "parent of <selector>" - jump to the parent of the nearest matching ancestor
385 match = domScope.match(/^parent\s+of\s+(.+)/);
386 if (match) {
387 var target = elt.closest(match[1]);
388 elt = target && target.parentElement;
389 continue;
390 }
391 }
392 elt = elt.parentElement;
393 }
394 return { value: undefined, element: null };
395 }
396
397 #getElementScope(context) {
398 var elt = context.meta && context.meta.owner;

Callers 2

resolveSymbolMethod · 0.95
setSymbolMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected