-
Notifications
You must be signed in to change notification settings - Fork 47.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Float][Fiber] Assume stylesheets in document are already loaded #29811
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,11 @@ export function completeBoundaryWithStyles( | |
const dependencies = []; | ||
let href, precedence, attr, loadingState, resourceEl, media; | ||
|
||
function cleanupWith(cb) { | ||
this['_p'] = null; | ||
cb(); | ||
} | ||
|
||
// Sheets Mode | ||
let sheetMode = true; | ||
while (true) { | ||
|
@@ -82,18 +87,14 @@ export function completeBoundaryWithStyles( | |
resourceEl.setAttribute(attr, stylesheetDescriptor[j++]); | ||
} | ||
loadingState = resourceEl['_p'] = new Promise((resolve, reject) => { | ||
resourceEl.onload = resolve; | ||
resourceEl.onerror = reject; | ||
resourceEl.onload = cleanupWith.bind(resourceEl, resolve); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be smaller to just inline the function like an arrow function. We probably compile them out but if we ever stop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need bind b/c i mutate the resourceEl the binding. not doing so leads to closure spitting out very large code b/c it gives the variable some enormous loop name |
||
resourceEl.onerror = cleanupWith.bind(resourceEl, reject); | ||
}); | ||
// Save this resource element so we can bailout if it is used again | ||
resourceMap.set(href, resourceEl); | ||
} | ||
media = resourceEl.getAttribute('media'); | ||
if ( | ||
loadingState && | ||
loadingState['s'] !== 'l' && | ||
(!media || window['matchMedia'](media).matches) | ||
) { | ||
if (loadingState && (!media || window['matchMedia'](media).matches)) { | ||
dependencies.push(loadingState); | ||
} | ||
if (avoidInsert) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check removed? If there is an existing style sheet why would we preload it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only call this function in one place and I changed it to gate the call on the instance not existing so we don't need to duplicate the check here