mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Make passing options to component optional
This commit is contained in:
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, {} );` : ``}
|
||||
|
||||
|
7
test/compiler/pass-no-options/_config.js
Normal file
7
test/compiler/pass-no-options/_config.js
Normal file
@ -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);
|
||||
}
|
||||
};
|
1
test/compiler/pass-no-options/main.html
Normal file
1
test/compiler/pass-no-options/main.html
Normal file
@ -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…
Reference in New Issue
Block a user