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

Commit

Permalink
fix duplicate CSS injection (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Sep 20, 2020
1 parent b06edba commit 43ab1e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 43ab1e9

Please sign in to comment.