Skip to content

[cssom] Application of existing stylesheet when href is modified #954

@ghost

Description

Should changing the href of a fully loaded and applied stylesheet to a slow loading url cause the current stylesheet to stop applying immediately?

Consider the case below. Firefox drops x-green-bg.css when the href is modified, while Chrome/Opera keeps the old style. That is, unless you also e.g. insert a new style element into the document. Then Chrome/Opera does the same as Firefox.

<!DOCTYPE html>
<link id="l" rel="stylesheet" href="x-green-bg.css">
<script>
    setTimeout(() => {
        l.href = "http://localhost:8000/resources/slow-image.php?sleep=3000&name=dummy.css&mimeType=text/css&expires=no";
        //var s = document.head.appendChild(document.createElement("style"));
        //s.innerHTML = "#x { color: red; }"
    }, 200);
</script>
<div id="x">Green background?</div>

x-green-bg.css:

#x { background:green }

Reported on request from @zcorpan

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions