diff --git a/src/compile/render-dom/Block.ts b/src/compile/render-dom/Block.ts
index 8a205e25fd..573a9863d8 100644
--- a/src/compile/render-dom/Block.ts
+++ b/src/compile/render-dom/Block.ts
@@ -409,12 +409,10 @@ export default class Block {
const localKey = this.key && this.getUniqueName('key');
return deindent`
- ${this.comment && `// ${escape(this.comment)}`}
- function ${this.name}(#component, ${this.key ? `${localKey}, ` : ''}ctx) {
+ ${this.comment && `// ${this.comment}`}
+ function ${this.name}(${this.alias('component')}, ${this.key ? `${localKey}, ` : ''}ctx) {
${this.getContents(localKey)}
}
- `.replace(/(#+)(\w*)/g, (match: string, sigil: string, name: string) => {
- return sigil === '#' ? this.alias(name) : sigil.slice(1) + name;
- });
+ `;
}
}
diff --git a/test/runtime/samples/hash-in-attribute/_config.js b/test/runtime/samples/hash-in-attribute/_config.js
new file mode 100644
index 0000000000..5e5726c48f
--- /dev/null
+++ b/test/runtime/samples/hash-in-attribute/_config.js
@@ -0,0 +1,26 @@
+export default {
+ preserveIdentifiers: true,
+
+ props: {
+ links: ['a', 'b', 'c']
+ },
+
+ html: `
+ x#a
+ x#b
+ x#c
+ `,
+
+ test({ assert, component, target }) {
+ component.links = ['d', 'e', 'f'];
+
+ const links = [...target.querySelectorAll('a')];
+ assert.deepEqual(links.map(l => l.href), ['x#d', 'x#e', 'x#f']);
+
+ assert.htmlEqual(target.innerHTML, `
+ x#d
+ x#e
+ x#f
+ `);
+ }
+};
\ No newline at end of file
diff --git a/test/runtime/samples/hash-in-attribute/main.html b/test/runtime/samples/hash-in-attribute/main.html
new file mode 100644
index 0000000000..0d1455b066
--- /dev/null
+++ b/test/runtime/samples/hash-in-attribute/main.html
@@ -0,0 +1,3 @@
+{#each links as link}
+ x#{link}
+{/each}
\ No newline at end of file