mirror of https://github.com/sveltejs/svelte
				
				
				
			assign custom methods to custom element prototype - fixes #1369
	
		
	
				
					
				
			
							parent
							
								
									890da3b02a
								
							
						
					
					
						commit
						ef39f00902
					
				@ -0,0 +1,13 @@
 | 
				
			||||
<p>{foo}</p>
 | 
				
			||||
 | 
				
			||||
<script>
 | 
				
			||||
	export default {
 | 
				
			||||
		tag: 'custom-element',
 | 
				
			||||
 | 
				
			||||
		methods: {
 | 
				
			||||
			updateFoo(value) {
 | 
				
			||||
				this.foo = value;
 | 
				
			||||
			}
 | 
				
			||||
		}
 | 
				
			||||
	};
 | 
				
			||||
</script>
 | 
				
			||||
@ -0,0 +1,12 @@
 | 
				
			||||
import * as assert from 'assert';
 | 
				
			||||
import './main.html';
 | 
				
			||||
 | 
				
			||||
export default function (target) {
 | 
				
			||||
	target.innerHTML = '<custom-element name="world"></custom-element>';
 | 
				
			||||
	const el = target.querySelector('custom-element');
 | 
				
			||||
 | 
				
			||||
	el.updateFoo(42);
 | 
				
			||||
 | 
				
			||||
	const p = el.shadowRoot.querySelector('p');
 | 
				
			||||
	assert.equal(p.textContent, '42');
 | 
				
			||||
}
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue