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

Function suspendResource

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

Source from the content-addressed store, hash-verified

17674var suspendedState = null;
17675function noop() {}
17676function suspendResource(hoistableRoot, resource, props) {
17677 if (null === suspendedState) throw Error(formatProdErrorMessage(475));
17678 var state = suspendedState;
17679 if (
17680 "stylesheet" === resource.type &&
17681 ("string" !== typeof props.media ||
17682 !1 !== matchMedia(props.media).matches) &&
17683 0 === (resource.state.loading & 4)
17684 ) {
17685 if (null === resource.instance) {
17686 var key = getStyleKey(props.href),
17687 instance = hoistableRoot.querySelector(
17688 getStylesheetSelectorFromKey(key)
17689 );
17690 if (instance) {
17691 hoistableRoot = instance._p;
17692 null !== hoistableRoot &&
17693 "object" === typeof hoistableRoot &&
17694 "function" === typeof hoistableRoot.then &&
17695 (state.count++,
17696 (state = onUnsuspend.bind(state)),
17697 hoistableRoot.then(state, state));
17698 resource.state.loading |= 4;
17699 resource.instance = instance;
17700 markNodeAsHoistable(instance);
17701 return;
17702 }
17703 instance = hoistableRoot.ownerDocument || hoistableRoot;
17704 props = stylesheetPropsFromRawProps(props);
17705 (key = preloadPropsMap.get(key)) &&
17706 adoptPreloadPropsForStylesheet(props, key);
17707 instance = instance.createElement("link");
17708 markNodeAsHoistable(instance);
17709 var linkInstance = instance;
17710 linkInstance._p = new Promise(function (resolve, reject) {
17711 linkInstance.onload = resolve;
17712 linkInstance.onerror = reject;
17713 });
17714 setInitialProperties(instance, "link", props);
17715 resource.instance = instance;
17716 }
17717 null === state.stylesheets && (state.stylesheets = new Map());
17718 state.stylesheets.set(resource, hoistableRoot);
17719 (hoistableRoot = resource.state.preload) &&
17720 0 === (resource.state.loading & 3) &&
17721 (state.count++,
17722 (resource = onUnsuspend.bind(state)),
17723 hoistableRoot.addEventListener("load", resource),
17724 hoistableRoot.addEventListener("error", resource));
17725 }
17726}
17727function waitForCommitToBeReady() {
17728 if (null === suspendedState) throw Error(formatProdErrorMessage(475));
17729 var state = suspendedState;

Callers 1

Calls 7

formatProdErrorMessageFunction · 0.85
getStyleKeyFunction · 0.85
markNodeAsHoistableFunction · 0.85
setInitialPropertiesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…