From 714974951c6d88f910455b34bca41201578815c5 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 19 Sep 2020 14:25:08 -0700 Subject: [PATCH 1/2] Fix duplicate css injection --- src/core/create_compilers/RollupCompiler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/create_compilers/RollupCompiler.ts b/src/core/create_compilers/RollupCompiler.ts index a1b28d962..76031d9b9 100644 --- a/src/core/create_compilers/RollupCompiler.ts +++ b/src/core/create_compilers/RollupCompiler.ts @@ -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'; From 63cb32b5d7c46bb6a0691f26fa907f6485fdbf91 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 20 Sep 2020 10:29:24 -0400 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59deffd70..bb74c0f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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