-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
Having gone back and forth on this, I think it makes more sense for components to be constructors rather than factories – i.e. instead of this...
export default function createComponent ( options ) {
// ...
}
...this:
export default function Widget ( options ) {
// ...
}
This makes Svelte components slightly more familiar for people coming from e.g. Ractive or Vue, and has this important benefit:
// awkward naming
import createWidget from './Widget.html';
const widget = createWidget(...);
// better
import Widget from './Widget.html';
const widget = new Widget(...);
(Capitalising filenames makes sense because inline components should also be capitalised, i.e. <Widget foo='bar'/>
– this is a good way to visually distinguish elements from components in a way that doesn't make them look like web components.)
Metadata
Metadata
Assignees
Labels
No labels