diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 8c5b4cb9f5..07f1739018 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -600,10 +600,12 @@ export default class Element extends Node { validate_bindings_foreign() { this.bindings.forEach(binding => { - this.component.error(binding, { - code: 'invalid-binding', - message: `'${binding.name}' is not a valid binding. Foreign elements only support bind:this` - }); + if (binding.name !== 'this') { + this.component.error(binding, { + code: 'invalid-binding', + message: `'${binding.name}' is not a valid binding. Foreign elements only support bind:this` + }); + } }); } diff --git a/test/validator/index.ts b/test/validator/index.ts index 72364ea89a..e58be87a3a 100644 --- a/test/validator/index.ts +++ b/test/validator/index.ts @@ -119,4 +119,17 @@ describe('validate', () => { }); }, /Invalid namespace 'foriegn' \(did you mean 'foreign'\?\)/); }); + + it('does not throw error if \'this\' is bound for foreign element', () => { + assert.doesNotThrow(() => { + svelte.compile(` + +
`, { + name: 'test', + namespace: 'foreign' + }); + }); + }); });