Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make and() and or() lazy #629

Open
justinbmeyer opened this issue Nov 15, 2018 · 0 comments
Open

Make and() and or() lazy #629

justinbmeyer opened this issue Nov 15, 2018 · 0 comments

Comments

@justinbmeyer
Copy link
Contributor

similar to && and ||, I think and() and or() should be lazy. For example, the following should pass:

QUnit.test("and is lazy", function(){
	var view = stache("<div>{{#and(this.isFalse, this.shouldNotBeRead)}}TRUE{{else}}FALSE{{/and}}</div>");

	var fragment = view({
		isFalse: false,
		shouldNotBeRead: new Observation(function avoidReadingThis(){
			QUnit.ok(false, "should not be read");
		})
	});

	QUnit.equal(fragment.firstChild.innerHTML,"FALSE", "evaled to false");
});

Currently this doesn't because Lookup() always Observation.temporarilyBind(data) so initialData can be peaked at ....

Lookup::value also warns about missing values. This would somehow have to be done later. Perhaps via some ScopeKeyData configuration ...

I think we'd want ScopeKeyData.initialValue to "temporary bind" if it's not already bound. This way, things that were already reading initialValue would still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants