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

Function preinitStyle

docs/index.js:17215–17263  ·  view source on GitHub ↗
(href, precedence, options)

Source from the content-addressed store, hash-verified

17213 }
17214}
17215function preinitStyle(href, precedence, options) {
17216 previousDispatcher.S(href, precedence, options);
17217 var ownerDocument = globalDocument;
17218 if (ownerDocument && href) {
17219 var styles = getResourcesFromRoot(ownerDocument).hoistableStyles,
17220 key = getStyleKey(href);
17221 precedence = precedence || "default";
17222 var resource = styles.get(key);
17223 if (!resource) {
17224 var state = { loading: 0, preload: null };
17225 if (
17226 (resource = ownerDocument.querySelector(
17227 getStylesheetSelectorFromKey(key)
17228 ))
17229 )
17230 state.loading = 5;
17231 else {
17232 href = assign(
17233 { rel: "stylesheet", href: href, "data-precedence": precedence },
17234 options
17235 );
17236 (options = preloadPropsMap.get(key)) &&
17237 adoptPreloadPropsForStylesheet(href, options);
17238 var link = (resource = ownerDocument.createElement("link"));
17239 markNodeAsHoistable(link);
17240 setInitialProperties(link, "link", href);
17241 link._p = new Promise(function (resolve, reject) {
17242 link.onload = resolve;
17243 link.onerror = reject;
17244 });
17245 link.addEventListener("load", function () {
17246 state.loading |= 1;
17247 });
17248 link.addEventListener("error", function () {
17249 state.loading |= 2;
17250 });
17251 state.loading |= 4;
17252 insertStylesheet(resource, precedence, ownerDocument);
17253 }
17254 resource = {
17255 type: "stylesheet",
17256 instance: resource,
17257 count: 1,
17258 state: state
17259 };
17260 styles.set(key, resource);
17261 }
17262 }
17263}
17264function preinitScript(src, options) {
17265 previousDispatcher.X(src, options);
17266 var ownerDocument = globalDocument;

Callers

nothing calls this directly

Calls 7

getResourcesFromRootFunction · 0.85
getStyleKeyFunction · 0.85
markNodeAsHoistableFunction · 0.85
setInitialPropertiesFunction · 0.85
insertStylesheetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…