@@ -156,6 +156,19 @@ export default function dom ( parsed, source, options, names ) {
156
156
157
157
const { computations, templateProperties } = generator . parseJs ( ) ;
158
158
159
+ // Remove these after version 2
160
+ if ( templateProperties . onrender ) {
161
+ const { key } = templateProperties . onrender ;
162
+ generator . code . overwrite ( key . start , key . end , 'oncreate' , true ) ;
163
+ templateProperties . oncreate = templateProperties . onrender ;
164
+ }
165
+
166
+ if ( templateProperties . onteardown ) {
167
+ const { key } = templateProperties . onteardown ;
168
+ generator . code . overwrite ( key . start , key . end , 'ondestroy' , true ) ;
169
+ templateProperties . ondestroy = templateProperties . onteardown ;
170
+ }
171
+
159
172
generator . imports . forEach ( node => {
160
173
node . specifiers . forEach ( specifier => {
161
174
generator . importedNames [ specifier . local . name ] = true ;
@@ -164,7 +177,7 @@ export default function dom ( parsed, source, options, names ) {
164
177
165
178
let namespace = null ;
166
179
if ( templateProperties . namespace ) {
167
- const ns = templateProperties . namespace . value ;
180
+ const ns = templateProperties . namespace . value . value ;
168
181
namespace = namespaces [ ns ] || ns ;
169
182
170
183
// TODO remove the namespace property from the generated code, it's unused past this point
@@ -281,12 +294,12 @@ export default function dom ( parsed, source, options, names ) {
281
294
builders . _set . addBlock ( statement ) ;
282
295
}
283
296
284
- if ( templateProperties . onrender ) {
297
+ if ( templateProperties . oncreate ) {
285
298
builders . init . addBlock ( deindent `
286
299
if ( options._root ) {
287
- options._root._renderHooks.push({ fn: template.onrender , context: this });
300
+ options._root._renderHooks.push({ fn: template.oncreate , context: this });
288
301
} else {
289
- template.onrender .call( this );
302
+ template.oncreate .call( this );
290
303
}
291
304
` ) ;
292
305
}
@@ -348,7 +361,7 @@ export default function dom ( parsed, source, options, names ) {
348
361
};
349
362
350
363
${ name } .prototype.teardown = function teardown ( detach ) {
351
- this.fire( 'teardown' );${ templateProperties . onteardown ? `\ntemplate.onteardown .call( this );` : `` }
364
+ this.fire( 'teardown' );${ templateProperties . ondestroy ? `\ntemplate.ondestroy .call( this );` : `` }
352
365
353
366
this._fragment.teardown( detach !== false );
354
367
this._fragment = null;
0 commit comments