correctly unescape @ symbols (#712)

pull/719/head
Rich Harris 7 years ago
parent 343d66538b
commit 7b3c69b348

@ -355,8 +355,8 @@ export default class Block {
${properties} ${properties}
}; };
} }
`.replace(/(\\)?#(\w*)/g, (match, escaped, name) => { `.replace(/(\\\\)?#(\w*)/g, (match, escaped, name) => {
return escaped ? match.slice(1) : this.alias(name); return escaped ? match.slice(2) : this.alias(name);
}); });
} }
} }

@ -137,15 +137,15 @@ export default function dom(
if (generator.stylesheet.hasStyles && options.css !== false) { if (generator.stylesheet.hasStyles && options.css !== false) {
const { css, cssMap } = generator.stylesheet.render(options.filename); const { css, cssMap } = generator.stylesheet.render(options.filename);
const textContent = options.dev ? const textContent = stringify(options.dev ?
`${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` : `${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` :
css; css);
builder.addBlock(deindent` builder.addBlock(deindent`
function @add_css () { function @add_css () {
var style = @createElement( 'style' ); var style = @createElement( 'style' );
style.id = '${generator.stylesheet.id}-style'; style.id = '${generator.stylesheet.id}-style';
style.textContent = ${JSON.stringify(textContent)}; style.textContent = ${textContent};
@appendNode( style, document.head ); @appendNode( style, document.head );
} }
`); `);
@ -263,8 +263,8 @@ export default function dom(
let result = builder let result = builder
.toString() .toString()
.replace(/(\\)?@(\w*)/g, (match: string, escaped: string, name: string) => { .replace(/(\\\\)?@(\w*)/g, (match: string, escaped: string, name: string) => {
if (escaped) return match.slice(1); if (escaped) return match.slice(2);
if (name in shared) { if (name in shared) {
if (options.dev && `${name}Dev` in shared) name = `${name}Dev`; if (options.dev && `${name}Dev` in shared) name = `${name}Dev`;

Loading…
Cancel
Save