Base scoping hashes on CSS content rather than entire file#1105
Base scoping hashes on CSS content rather than entire file#1105emilos wants to merge 1 commit intosveltejs:masterfrom emilos:issue-1091
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1105 +/- ##
==========================================
+ Coverage 91.56% 91.57% +<.01%
==========================================
Files 123 123
Lines 4493 4496 +3
Branches 1447 1448 +1
==========================================
+ Hits 4114 4117 +3
Misses 162 162
Partials 217 217
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| function getHashSource (parser: Parser, options: ParserOptions) { | ||
| if (options.css === false || !parser.css) { |
There was a problem hiding this comment.
I don't think options.css being false is a reason to use parser.template. If options.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 parse parser.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 this getHashSource function and to below simply replace hash: hash(parser.template) with hash: parser.css && hash(parser.css.content.styles).
There was a problem hiding this comment.
hey, thanks for the quick reply :)
I had a similar thought at first but I wasn't sure if hash value being set as null | undefined would be an expected value for a hash. Another reason for using the options.css flag is due to the test/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.
There was a problem hiding this comment.
@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:
hash: parser.css && hash(parser.css.content.styles)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
|
Thanks @emilos! I was wondering if we should keep the existing |
|
In what way might this be a breaking change for anyone? The edit: Oh, shit, forgot we exposed the |
|
Yeah, removing it isn't likely to cause problems, I just feel like it's easier that way. Otherwise I'd advocate for removing |
|
I found it a little bit confusing that the parser does return a hash that is used elsewhere. Right now it is used only in the I think it would be most straightforward to add a new We could probably also add something like that to I'm fine with any option you guys decide is best. Getting back to the question above, @Rich-Harris do you have any idea why the |
|
Opened #1119 which bases the Am baffled by the test failure, haven't been able to figure it out yet. |
|
Ok, I figured it out — the CSS tests were leaving |
|
@Rich-Harris cool 👍 thanks! I'll close this one then |
Attempt to close #1091 :)