コード例 #1
0
ファイル: bubble.js プロジェクト: Writhe/ractive
export default function Attribute$bubble () {
	var value = this.fragment.getValue();

	// TODO this can register the attribute multiple times (see render test
	// 'Attribute with nested mustaches')
	if ( value !== this.value ) {

		// Need to clear old id from ractive.nodes
		if ( this.name === 'id' && this.value ) {
			delete this.root.nodes[ this.value ];
		}

		this.value = value;

		if ( this.name === 'value' && this.node ) {
			// We need to store the value on the DOM like this so we
			// can retrieve it later without it being coerced to a string
			this.node._ractive.value = value;
		}

		if ( this.rendered ) {
			runloop.addView( this );
		}
	}
}
コード例 #2
0
ファイル: setValue.js プロジェクト: AmitAber/ractive
export default function Section$setValue ( value ) {
	var wrapper, fragmentOptions;

	if ( this.updating ) {
		// If a child of this section causes a re-evaluation - for example, an
		// expression refers to a function that mutates the array that this
		// section depends on - we'll end up with a double rendering bug (see
		// https://github.com/ractivejs/ractive/issues/748). This prevents it.
		return;
	}

	this.updating = true;

	// with sections, we need to get the fake value if we have a wrapped object
	if ( wrapper = this.root.viewmodel.wrapped[ this.keypath ] ) {
		value = wrapper.get();
	}

	// If any fragments are awaiting creation after a splice,
	// this is the place to do it
	if ( this.fragmentsToCreate.length ) {
		fragmentOptions = {
			template: this.template.f,
			root:     this.root,
			pElement: this.pElement,
			owner:    this,
			indexRef: this.template.i
		};

		this.fragmentsToCreate.forEach( index => {
			var fragment;

			fragmentOptions.context = this.keypath + '.' + index;
			fragmentOptions.index = index;

			fragment = new Fragment( fragmentOptions );
			this.fragmentsToRender.push( this.fragments[ index ] = fragment );
		});

		this.fragmentsToCreate.length = 0;
	}

	else if ( reevaluateSection( this, value ) ) {
		this.bubble();

		if ( this.rendered ) {
			runloop.addView( this );
		}
	}

	this.value = value;
	this.updating = false;
}
コード例 #3
0
ファイル: Interpolator.js プロジェクト: AmitAber/ractive
	setValue: function ( value ) {
		var wrapper;

		// TODO is there a better way to approach this?
		if ( wrapper = this.root.viewmodel.wrapped[ this.keypath ] ) {
			value = wrapper.get();
		}

		if ( !isEqual( value, this.value ) ) {
			this.value = value;
			this.parentFragment.bubble();

			if ( this.node ) {
				runloop.addView( this );
			}
		}
	},
コード例 #4
0
ファイル: setValue.js プロジェクト: AndreaMorone/ractive
export default function Triple$setValue ( value ) {
	var wrapper;

	// TODO is there a better way to approach this?
	if ( wrapper = this.root.viewmodel.wrapped[ this.keypath.str ] ) {
		value = wrapper.get();
	}

	if ( value !== this.value ) {
		this.value = value;
		this.parentFragment.bubble();

		if ( this.rendered ) {
			runloop.addView( this );
		}
	}
}
コード例 #5
0
ファイル: _Partial.js プロジェクト: markandrewj/ractive
	setValue: function( value ) {
		if ( this.value !== value ) {
			if ( this.fragment && this.rendered ) {
				this.fragment.unrender( true );
			}

			this.fragment = null;
			this.value = value;

			if ( this.rendered ) {
				runloop.addView( this );
			} else {
				this.update();
				this.bubble();
			}
		}
	},
コード例 #6
0
ファイル: ComponentParameter.js プロジェクト: MrGRA/ractive
	bubble: function () {
		if ( !this.dirty ) {
			this.dirty = true;
			runloop.addView( this );
		}
	},
コード例 #7
0
ファイル: _Partial.js プロジェクト: AndreaMorone/ractive
			unbind.call( this );
			this.isNamed = true;
		}

		if ( !template ) {
			warnOnceIfDebug( missingPartialMessage, this.name, { ractive: this.root });
		}

		this.value = value;

		this.setTemplate( template || [] );

		this.bubble();

		if ( this.rendered ) {
			runloop.addView( this );
		}
	},

	setTemplate ( template ) {
		if ( this.fragment ) {
			this.fragment.unbind();
			if ( this.rendered ) {
				this.fragmentToUnrender = this.fragment;
			}
		}

		this.fragment = new Fragment({
			template,
			root: this.root,
			owner: this,