Skip to content

Commit 9fbcddf

Browse files
committed
base stylesheet.hash on css content, and revert parsed.hash
1 parent df5a32a commit 9fbcddf

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/css/Stylesheet.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { walk } from 'estree-walker';
33
import { getLocator } from 'locate-character';
44
import Selector from './Selector';
55
import getCodeFrame from '../utils/getCodeFrame';
6+
import hash from '../utils/hash';
67
import Element from '../generators/nodes/Element';
78
import { Validator } from '../validate/index';
89
import { Node, Parsed, Warning } from '../interfaces';
@@ -269,12 +270,12 @@ export default class Stylesheet {
269270
this.cascade = cascade;
270271
this.filename = filename;
271272

272-
this.id = `svelte-${parsed.hash}`;
273-
274273
this.children = [];
275274
this.keyframes = new Map();
276275

277276
if (parsed.css && parsed.css.children.length) {
277+
this.id = `svelte-${hash(parsed.css.content.styles)}`;
278+
278279
this.hasStyles = true;
279280

280281
const stack: (Rule | Atrule)[] = [];

src/parse/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { trimStart, trimEnd } from '../utils/trim';
66
import getCodeFrame from '../utils/getCodeFrame';
77
import reservedNames from '../utils/reservedNames';
88
import fullCharCodeAt from '../utils/fullCharCodeAt';
9-
import hash from './utils/hash';
9+
import hash from '../utils/hash';
1010
import { Node, Parsed } from '../interfaces';
1111
import CompileError from '../utils/CompileError';
1212

@@ -202,20 +202,13 @@ export class Parser {
202202
}
203203
}
204204

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-
212205
export default function parse(
213206
template: string,
214207
options: ParserOptions = {}
215208
): Parsed {
216209
const parser = new Parser(template, options);
217210
return {
218-
hash: hash(getHashSource(parser, options)),
211+
hash: hash(parser.template),
219212
html: parser.html,
220213
css: parser.css,
221214
js: parser.js,
File renamed without changes.

0 commit comments

Comments
 (0)