File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/compiler/compile/nodes Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -600,10 +600,12 @@ export default class Element extends Node {
600600
601601 validate_bindings_foreign ( ) {
602602 this . bindings . forEach ( binding => {
603- this . component . error ( binding , {
604- code : 'invalid-binding' ,
605- message : `'${ binding . name } ' is not a valid binding. Foreign elements only support bind:this`
606- } ) ;
603+ if ( binding . name !== 'this' ) {
604+ this . component . error ( binding , {
605+ code : 'invalid-binding' ,
606+ message : `'${ binding . name } ' is not a valid binding. Foreign elements only support bind:this`
607+ } ) ;
608+ }
607609 } ) ;
608610 }
609611
Original file line number Diff line number Diff line change @@ -119,4 +119,17 @@ describe('validate', () => {
119119 } ) ;
120120 } , / I n v a l i d n a m e s p a c e ' f o r i e g n ' \( d i d y o u m e a n ' f o r e i g n ' \? \) / ) ;
121121 } ) ;
122+
123+ it ( 'does not throw error if \'this\' is bound for foreign element' , ( ) => {
124+ assert . doesNotThrow ( ( ) => {
125+ svelte . compile ( `
126+ <script>
127+ let whatever;
128+ </script>
129+ <div bind:this={whatever} />` , {
130+ name : 'test' ,
131+ namespace : 'foreign'
132+ } ) ;
133+ } ) ;
134+ } ) ;
122135} ) ;
You can’t perform that action at this time.
0 commit comments