MCPcopy Index your code
hub / github.com/caseywebdev/react-list / acquireResource

Function acquireResource

docs/index.js:17458–17549  ·  view source on GitHub ↗
(hoistableRoot, resource, props)

Source from the content-addressed store, hash-verified

17456 return "script[async]" + key;
17457}
17458function acquireResource(hoistableRoot, resource, props) {
17459 resource.count++;
17460 if (null === resource.instance)
17461 switch (resource.type) {
17462 case "style":
17463 var instance = hoistableRoot.querySelector(
17464 'style[data-href~="' +
17465 escapeSelectorAttributeValueInsideDoubleQuotes(props.href) +
17466 '"]'
17467 );
17468 if (instance)
17469 return (
17470 (resource.instance = instance),
17471 markNodeAsHoistable(instance),
17472 instance
17473 );
17474 var styleProps = assign({}, props, {
17475 "data-href": props.href,
17476 "data-precedence": props.precedence,
17477 href: null,
17478 precedence: null
17479 });
17480 instance = (hoistableRoot.ownerDocument || hoistableRoot).createElement(
17481 "style"
17482 );
17483 markNodeAsHoistable(instance);
17484 setInitialProperties(instance, "style", styleProps);
17485 insertStylesheet(instance, props.precedence, hoistableRoot);
17486 return (resource.instance = instance);
17487 case "stylesheet":
17488 styleProps = getStyleKey(props.href);
17489 var instance$248 = hoistableRoot.querySelector(
17490 getStylesheetSelectorFromKey(styleProps)
17491 );
17492 if (instance$248)
17493 return (
17494 (resource.state.loading |= 4),
17495 (resource.instance = instance$248),
17496 markNodeAsHoistable(instance$248),
17497 instance$248
17498 );
17499 instance = stylesheetPropsFromRawProps(props);
17500 (styleProps = preloadPropsMap.get(styleProps)) &&
17501 adoptPreloadPropsForStylesheet(instance, styleProps);
17502 instance$248 = (
17503 hoistableRoot.ownerDocument || hoistableRoot
17504 ).createElement("link");
17505 markNodeAsHoistable(instance$248);
17506 var linkInstance = instance$248;
17507 linkInstance._p = new Promise(function (resolve, reject) {
17508 linkInstance.onload = resolve;
17509 linkInstance.onerror = reject;
17510 });
17511 setInitialProperties(instance$248, "link", instance);
17512 resource.state.loading |= 4;
17513 insertStylesheet(instance$248, props.precedence, hoistableRoot);
17514 return (resource.instance = instance$248);
17515 case "script":

Callers 1

Calls 12

markNodeAsHoistableFunction · 0.85
setInitialPropertiesFunction · 0.85
insertStylesheetFunction · 0.85
getStyleKeyFunction · 0.85
getScriptKeyFunction · 0.85
getScriptSelectorFromKeyFunction · 0.85
formatProdErrorMessageFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…