define([
	'config/types',
	'utils/warn',
	'render/DomFragment/Component/initialise/createModel/_createModel',
	'render/DomFragment/Component/initialise/createInstance',
	'render/DomFragment/Component/initialise/createObservers',
	'render/DomFragment/Component/initialise/propagateEvents',
	'render/DomFragment/Component/initialise/updateLiveQueries'
], function (
	types,
	warn,
	createModel,
	createInstance,
	createObservers,
	propagateEvents,
	updateLiveQueries
) {

	'use strict';

	return function ( component, options, docFrag ) {
		var parentFragment,
			root,
			Component,
			data,
			toBind;

		parentFragment = component.parentFragment = options.parentFragment;
		root = parentFragment.root;

		component.root = root;
		component.type = types.COMPONENT;
		component.name = options.descriptor.e;
		component.index = options.index;

		// we may need to create some observers to handle data-binding
		// between parent and child
		component.observers = [];

		// get the component constructor
		Component = root.components[ options.descriptor.e ];

		if ( !Component ) {
			throw new Error( 'Component "' + options.descriptor.e + '" not found' );
		}

		// First, we need to create a model for the component - e.g. if we
		// encounter <widget foo='bar'/> then we need to create a widget
		// with `data: { foo: 'bar' }`.
		//
		// This may involve setting up some bindings, but we can't do it
		// yet so we take some notes instead
		toBind = [];
		data = createModel( component, options.descriptor.a, toBind );

		createInstance( component, Component, data, docFrag, options.descriptor.f );
		createObservers( component, toBind );
		propagateEvents( component );

		// intro, outro and decorator directives have no effect
		if ( options.descriptor.t1 || options.descriptor.t2 || options.descriptor.o ) {
			warn( 'The "intro", "outro" and "decorator" directives have no effect on components' );
		}

		updateLiveQueries( component );
	};

});
define([
	'config/types',
	'utils/warn',
	'render/DomFragment/Component/initialise/createModel/_createModel',
	'render/DomFragment/Component/initialise/createInstance',
	'render/DomFragment/Component/initialise/createObservers',
	'render/DomFragment/Component/initialise/propagateEvents',
	'render/DomFragment/Component/initialise/updateLiveQueries'
], function (
	types,
	warn,
	createModel,
	createInstance,
	createObservers,
	propagateEvents,
	updateLiveQueries
) {

	'use strict';

	return function ( component, options, docFrag ) {
		var parentFragment,
			root,
			Component,
			data,
			toBind;

		parentFragment = component.parentFragment = options.parentFragment;
		root = parentFragment.root;

		component.root = root;
		component.type = types.COMPONENT;
		component.name = options.descriptor.e;
		component.index = options.index;

		// we may need to create some observers to handle data-binding
		// between parent and child
		component.observers = [];

		// get the component constructor
		Component = root.components[ options.descriptor.e ];

		if ( !Component ) {
			throw new Error( 'Component "' + options.descriptor.e + '" not found' );
		}

		// First, we need to create a model for the component - e.g. if we
		// encounter <widget foo='bar'/> then we need to create a widget
		// with `data: { foo: 'bar' }`.
		//
		// This may involve setting up some bindings, but we can't do it
		// yet so we take some notes instead
		toBind = [];
		data = createModel( component, options.descriptor.a, toBind );

		createInstance( component, Component, data, docFrag, options.descriptor.f );
		createObservers( component, toBind );
		propagateEvents( component, options.descriptor.v );

		// intro, outro and decorator directives have no effect
		if ( options.descriptor.t1 || options.descriptor.t2 || options.descriptor.o ) {
			warn( 'The "intro", "outro" and "decorator" directives have no effect on components' );
		}

		updateLiveQueries( component );
	};

});
fix broken component event propagation