fix: "foreign" namespace elements should still allow binding 'this' (#5942)

pull/5958/head
Saurav Sahu 4 years ago committed by GitHub
parent eeeeb49986
commit 87417e5a7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -600,10 +600,12 @@ export default class Element extends Node {
validate_bindings_foreign() { validate_bindings_foreign() {
this.bindings.forEach(binding => { this.bindings.forEach(binding => {
this.component.error(binding, { if (binding.name !== 'this') {
code: 'invalid-binding', this.component.error(binding, {
message: `'${binding.name}' is not a valid binding. Foreign elements only support bind:this` code: 'invalid-binding',
}); message: `'${binding.name}' is not a valid binding. Foreign elements only support bind:this`
});
}
}); });
} }

@ -119,4 +119,17 @@ describe('validate', () => {
}); });
}, /Invalid namespace 'foriegn' \(did you mean 'foreign'\?\)/); }, /Invalid namespace 'foriegn' \(did you mean 'foreign'\?\)/);
}); });
it('does not throw error if \'this\' is bound for foreign element', () => {
assert.doesNotThrow(() => {
svelte.compile(`
<script>
let whatever;
</script>
<div bind:this={whatever} />`, {
name: 'test',
namespace: 'foreign'
});
});
});
}); });

Loading…
Cancel
Save