[rel=preload] CSS won't load when <link rel=preload as=style> is removed before the style linking tag
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | unaffected |
People
(Reporter: mayhemer, Unassigned)
References
(Regression)
Details
(Keywords: regression)
Needs D71379 and all children applied to take effect
The new preload-as-speculative-load code creates the request for a style using the same code path as a speculative load. But it also cancels the loading channel when the (last) <link preload> node is removed. This interferes with the css loader coalescing logic. The cancelled load is left in the css loader's mLoadingDatas and when the actual style tag initiated load finds it, it is in a failed (cancelled) state and makes the style to fail to load.
My idea was to tell the css loader the channel, and thus the whole load, has been cancelled because it didn't have a use, so that an actual tag would start a whole new load.
One way is to mark the SheetLoadData
somehow as "dead" and make Loader::LoadSheet
ignore that existingData
here.
Other way is to remove the SheetLoadData
from the loader somehow, but my knowledge is weak to do it right.
Yet another way would be to join the preload coalescing logic and css loader coalescing logic somehow together.
POC ():
<body>
<script>
window.addEventListener('load', _ => {
const l = document.createElement("link");
l.as = "style";
l.rel = "preload";
l.href = "css2.css";
document.head.appendChild(l); // <-- calls Loader::LoadSheet
setTimeout(_ => {
l.remove(); // <-- cancels the loading channel with an error code, but doesn't tell the css loader about it
setTimeout(_ => {
const s = document.createElement("link");
s.rel = "stylesheet";
s.href = "css2.css";
document.head.appendChild(s); // <-- calls Loader::LoadSheet, which finds existing SheetLoadData created by the preload
}, 0);
}, 0);
});
</script>
</body>
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
Reporter | ||
Comment 1•4 years ago
|
||
Fixing bug 1636106 removes this problem.
Updated•4 years ago
|
Description
•