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}
};
}
`.replace(/(\\)?#(\w*)/g, (match, escaped, name) => {
return escaped ? match.slice(1) : this.alias(name);
`.replace(/(\\\\)?#(\w*)/g, (match, escaped, name) => {
return escaped ? match.slice(2) : this.alias(name);
});
}
}

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

Loading…
Cancel
Save