Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Fix duplicate css injection #1536

Merged
merged 3 commits into from Sep 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
* Minify and hash inject_styles.js [#1524](https://github.com/sveltejs/sapper/pull/1524)
* Fix support for legacy browsers [#1525](https://github.com/sveltejs/sapper/pull/1525)
* Fix flash of unstyled content [#1531](https://github.com/sveltejs/sapper/issues/1531)
* Fix duplicate CSS injection with both relative and absolute URLs [#1535](https://github.com/sveltejs/sapper/issues/1535)

## 0.28.7

Expand Down
4 changes: 3 additions & 1 deletion src/core/create_compilers/RollupCompiler.ts
Expand Up @@ -25,7 +25,9 @@ const inject_styles = `
export default function(files) {
return Promise.all(files.map(function(file) { return new Promise(function(fulfil, reject) {
var href = new URL(file, import.meta.url);
var link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
var relative = ('' + href).substring(document.baseURI.length);
var link = document.querySelector('link[rel=stylesheet][href="' + relative + '"]')
|| document.querySelector('link[rel=stylesheet][href="' + href + '"]');
if (!link) {
link = document.createElement('link');
link.rel = 'stylesheet';
Expand Down