Make passing options to component optional

pull/146/head
Fabrice Weinberg 8 years ago
parent ecf05ad36e
commit 65b10f6d5e

@ -433,6 +433,8 @@ export default function generate ( parsed, source, options, names ) {
topLevelStatements.push( deindent`
function ${constructorName} ( options ) {
options = options || {};
var component = this;${generator.usesRefs ? `\nthis.refs = {}` : ``}
var state = ${initialState};${templateProperties.computed ? `\napplyComputations( state, state, {} );` : ``}

@ -0,0 +1,7 @@
export default {
html: '<h1>Just some static HTML</h1>',
test: function ( assert, component, target, window ) {
const newComp = new window.SvelteComponent();
assert.equal(newComp instanceof window.SvelteComponent, true);
}
};

@ -0,0 +1 @@
<h1>Just some static HTML</h1>

@ -279,6 +279,9 @@ describe( 'svelte', () => {
return env()
.then( window => {
// Put the constructor on window for testing
window.SvelteComponent = SvelteComponent;
const target = window.document.querySelector( 'main' );
const component = new SvelteComponent({

Loading…
Cancel
Save