-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Base scoping hashes on CSS content rather than entire file #1105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
div[svelte-1408461649],[svelte-1408461649] div{color:red} | ||
div[svelte-1580141456],[svelte-1580141456] div{color:green} | ||
div[svelte-724714405],[svelte-724714405] div{color:red} | ||
div[svelte-300476157],[svelte-300476157] div{color:green} |
6 changes: 3 additions & 3 deletions
6
test/server-side-rendering/samples/styles-nested/_actual.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div svelte-1408461649>red</div> | ||
<div svelte-1580141456>green: foo</div> | ||
<div svelte-724714405>red</div> | ||
<div svelte-300476157>green: foo</div> | ||
|
||
|
||
|
||
<div svelte-1580141456>green: bar</div> | ||
<div svelte-300476157>green: bar</div> | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
test/server-side-rendering/samples/styles-nested/_expected.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
div[svelte-1408461649],[svelte-1408461649] div{color:red} | ||
div[svelte-1580141456],[svelte-1580141456] div{color:green} | ||
div[svelte-724714405],[svelte-724714405] div{color:red} | ||
div[svelte-300476157],[svelte-300476157] div{color:green} |
6 changes: 3 additions & 3 deletions
6
test/server-side-rendering/samples/styles-nested/_expected.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div svelte-1408461649>red</div> | ||
<div svelte-1580141456>green: foo</div> | ||
<div svelte-724714405>red</div> | ||
<div svelte-300476157>green: foo</div> | ||
|
||
|
||
|
||
<div svelte-1580141456>green: bar</div> | ||
<div svelte-300476157>green: bar</div> | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
div[svelte-2278551596],[svelte-2278551596] div{color:red} | ||
div[svelte-724714405],[svelte-724714405] div{color:red} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div svelte-2278551596>red</div> | ||
<div svelte-724714405>red</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
div[svelte-2278551596],[svelte-2278551596] div{color:red} | ||
div[svelte-724714405],[svelte-724714405] div{color:red} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div svelte-2278551596>red</div> | ||
<div svelte-724714405>red</div> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
options.css
being false is a reason to useparser.template
. Ifoptions.css
is false, that just means the user doesn't want to have code to inject the<style>
, and they will make sure they get the styles another way.If
parser.css
is null/undefined, I'm also not sure why we'd need to parseparser.template
. In that case, doesn't Svelte just not add the extra attributes to any elements, and thus it doesn't need to have a hash? It seems like it might be possible to not have thisgetHashSource
function and to below simply replacehash: hash(parser.template)
withhash: parser.css && hash(parser.css.content.styles)
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, thanks for the quick reply :)
I had a similar thought at first but I wasn't sure if
hash
value being set asnull | undefined
would be an expected value for a hash. Another reason for using theoptions.css
flag is due to thetest/runtime/samples/css-false
spec, but I might've understood its intent in a wrong way.After looking at it second time I'm not sure where the logic for the
css-false
spec sits, I'll try to investigate.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Conduitry just fyi, I've investigated further and I've run into a weird scenario :) if I focus on given spec and change the code to:
it fails when all specs are run, but it passes correctly when the spec is focused with
solo: true
(it's not random and happens in 100% cases). Any ideas what could be happening? I guess it is happening since the tests are not isolated but I wasn't able to narrow down the issue yet