This might be taking things too far, but it occurs to me that we don't really need the template object in a lot of cases. This code...
<div></div>
<script>
export default {
oncreate() {
alert('hello');
}
};
</script>
...could become this:
-var template = (function () {
- return {
- oncreate() {
- alert('hello');
- }
- };
-}());
+function oncreate() {
+ alert('hello')
+}
function create_main_fragment ( state, component ) {
//...
}
function App ( options ) {
// ...
- var oncreate = template.oncreate.bind( this );
+ var _oncreate = oncreate.bind( this );
if ( !options._root ) {
- this._oncreate = [oncreate];
+ this._oncreate = [_oncreate];
} else {
- this._root._oncreate.push(oncreate);
+ this._root._oncreate.push(_oncreate);
}
// ...
}
We're already doing this for stuff like components — if we did if for computed properties, lifecycle hooks and so on, we'd end up with leaner (and more minifiable) code.
(Done naively, the resulting indentation would be all wrong, which 100% doesn't matter but would drive me mental. So I would want to reindent all the user code, unless someone can talk me out of that.)
This might be taking things too far, but it occurs to me that we don't really need the
templateobject in a lot of cases. This code......could become this:
We're already doing this for stuff like
components— if we did if for computed properties, lifecycle hooks and so on, we'd end up with leaner (and more minifiable) code.(Done naively, the resulting indentation would be all wrong, which 100% doesn't matter but would drive me mental. So I would want to reindent all the user code, unless someone can talk me out of that.)