pull/709/head
Rich Harris 8 years ago
parent 3f65b8b38f
commit 1733966d18

@ -207,18 +207,16 @@ export default function dom(
${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`}
// TODO maybe only nec if we have components...
if ( !options._root ) {
// this._bindings = [];
this._beforecreate = [];
this._oncreate = [${templateProperties.oncreate && `oncreate`}];
this._aftercreate = [];
}
${templateProperties.oncreate && deindent`
else {
this._root._oncreate.push(oncreate);
}
${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent`
if ( !options._root ) {
this._oncreate = [${templateProperties.oncreate && `oncreate`}];
${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`}
${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`}
} ${templateProperties.oncreate && deindent`
else {
this._root._oncreate.push(oncreate);
}
`}
`}
this._fragment = @create_main_fragment( this._state, this );
@ -237,9 +235,9 @@ export default function dom(
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null );
}
@callAll(this._beforecreate);
@callAll(this._oncreate);
@callAll(this._aftercreate);
${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`}
${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`}
${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`}
}
@assign( ${prototypeBase}, ${proto});

@ -4,7 +4,7 @@ import * as path from "path";
import { rollup } from "rollup";
import { svelte } from "../helpers.js";
describe.skip("js", () => {
describe("js", () => {
fs.readdirSync("test/js/samples").forEach(dir => {
if (dir[0] === ".") return;

@ -115,7 +115,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -91,7 +91,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -124,7 +124,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -109,7 +109,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -115,7 +115,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -115,7 +115,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

@ -103,7 +103,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {
@ -178,7 +180,12 @@ function SvelteComponent ( options ) {
this._yield = options._yield;
this._torndown = false;
this._oncreate = [];
if ( !options._root ) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment( this._state, this );
@ -187,7 +194,9 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null );
}
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
}
assign( SvelteComponent.prototype, proto );
@ -197,7 +206,6 @@ SvelteComponent.prototype._set = function _set ( newState ) {
this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState );
callAll(this._oncreate);
};
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {

@ -62,7 +62,12 @@ function SvelteComponent ( options ) {
this._yield = options._yield;
this._torndown = false;
this._oncreate = [];
if ( !options._root ) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment( this._state, this );
@ -71,7 +76,9 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null );
}
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
}
assign( SvelteComponent.prototype, proto );
@ -81,7 +88,6 @@ SvelteComponent.prototype._set = function _set ( newState ) {
this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState );
callAll(this._oncreate);
};
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {

@ -91,7 +91,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {
@ -143,18 +145,21 @@ function SvelteComponent ( options ) {
this._torndown = false;
var oncreate = template.oncreate.bind( this );
if ( !options._root ) {
this._oncreate = [oncreate];
} else {
this._root._oncreate.push(oncreate);
}
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, null );
}
if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) );
} else {
template.oncreate.call( this );
}
callAll(this._oncreate);
}
assign( SvelteComponent.prototype, proto );

@ -1,4 +1,4 @@
import { assign, dispatchObservers, noop, proto } from "svelte/shared.js";
import { assign, callAll, dispatchObservers, noop, proto } from "svelte/shared.js";
var template = (function () {
return {
@ -37,18 +37,21 @@ function SvelteComponent ( options ) {
this._torndown = false;
var oncreate = template.oncreate.bind( this );
if ( !options._root ) {
this._oncreate = [oncreate];
} else {
this._root._oncreate.push(oncreate);
}
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, null );
}
if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) );
} else {
template.oncreate.call( this );
}
callAll(this._oncreate);
}
assign( SvelteComponent.prototype, proto );

@ -115,7 +115,9 @@ function on(eventName, handler) {
function set(newState) {
this._set(assign({}, newState));
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
}
function callAll(fns) {

Loading…
Cancel
Save