File tree 3 files changed +5
-11
lines changed 3 files changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { walk } from 'estree-walker';
3
3
import { getLocator } from 'locate-character' ;
4
4
import Selector from './Selector' ;
5
5
import getCodeFrame from '../utils/getCodeFrame' ;
6
+ import hash from '../utils/hash' ;
6
7
import Element from '../generators/nodes/Element' ;
7
8
import { Validator } from '../validate/index' ;
8
9
import { Node , Parsed , Warning } from '../interfaces' ;
@@ -269,12 +270,12 @@ export default class Stylesheet {
269
270
this . cascade = cascade ;
270
271
this . filename = filename ;
271
272
272
- this . id = `svelte-${ parsed . hash } ` ;
273
-
274
273
this . children = [ ] ;
275
274
this . keyframes = new Map ( ) ;
276
275
277
276
if ( parsed . css && parsed . css . children . length ) {
277
+ this . id = `svelte-${ hash ( parsed . css . content . styles ) } ` ;
278
+
278
279
this . hasStyles = true ;
279
280
280
281
const stack : ( Rule | Atrule ) [ ] = [ ] ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { trimStart, trimEnd } from '../utils/trim';
6
6
import getCodeFrame from '../utils/getCodeFrame' ;
7
7
import reservedNames from '../utils/reservedNames' ;
8
8
import fullCharCodeAt from '../utils/fullCharCodeAt' ;
9
- import hash from './utils/hash' ;
9
+ import hash from '.. /utils/hash' ;
10
10
import { Node , Parsed } from '../interfaces' ;
11
11
import CompileError from '../utils/CompileError' ;
12
12
@@ -202,20 +202,13 @@ export class Parser {
202
202
}
203
203
}
204
204
205
- function getHashSource ( parser : Parser , options : ParserOptions ) {
206
- if ( options . css === false || ! parser . css ) {
207
- return parser . template ;
208
- }
209
- return parser . css . content . styles ;
210
- }
211
-
212
205
export default function parse (
213
206
template : string ,
214
207
options : ParserOptions = { }
215
208
) : Parsed {
216
209
const parser = new Parser ( template , options ) ;
217
210
return {
218
- hash : hash ( getHashSource ( parser , options ) ) ,
211
+ hash : hash ( parser . template ) ,
219
212
html : parser . html ,
220
213
css : parser . css ,
221
214
js : parser . js ,
File renamed without changes.
You can’t perform that action at this time.
0 commit comments