Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support v-if multiple conditions #4271

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

Merged
merged 15 commits into from
Nov 21, 2016
Merged

Support v-if multiple conditions #4271

merged 15 commits into from
Nov 21, 2016

Conversation

defcc
Copy link
Member

@defcc defcc commented Nov 21, 2016

Support v-if multiple conditions

<div v-if="tester1"></div>
<div v-elseif="tester2"></div>
<div v-elseif="tester3"></div>
<div v-else></div>

Collects if and v-elseif and v-else into element.conditions when parsing and generates code like (a)?_h:(c)?_h:_e()

@defcc defcc changed the title Support v-if multiple conditions [wip]Support v-if multiple conditions Nov 21, 2016
@defcc defcc changed the title [wip]Support v-if multiple conditions Support v-if multiple conditions Nov 21, 2016
@blake-newman
Copy link
Member

v-elseif or v-else-if?

Latter might be better for non-native users

@yyx990803 yyx990803 merged commit af78bcf into vuejs:dev Nov 21, 2016
@@ -41,6 +41,7 @@ declare type ModuleOptions = {
}

declare type ASTModifiers = { [key: string]: boolean }
declare type ASTIfConditions = Array<{ exp: ?string; block: ASTElement }>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this doing

else?: true;
elseBlock?: ASTElement;
conditions?: ASTIfConditions;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

}).$mount()
expect(vm.$el.innerHTML.trim()).toBe('<span>hello</span>')
vm.foo = false
waitForUpdate(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the waitForUpdate magic

vm.bar = true
}).then(() => {
expect(vm.$el.innerHTML.trim()).toBe('<span>elseif</span>')
vm.bar = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it wants a then chaining,

+      expect(vm.$el.innerHTML.trim()).toBe('<span>elseif</span>')
+      vm.bar = false

should return a promise,
but I see no promise T.T

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnlctrl help wanted XD

vm.bar = 0
}).then(() => {
expect(vm.$el.innerHTML.trim()).toBe('<span>bye</span>')
vm.bar = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would it be necessary for so many kind of vm.bar @fnlctrl

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

Successfully merging this pull request may close these issues.

4 participants