Skip to content

Commit

Permalink
refactor: tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 8, 2017
1 parent f3fe012 commit 96b9744
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/platforms/web/compiler/modules/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
if (map['v-model'] && (map['v-bind:type'] || map[':type'])) {
const typeBinding: any = getBindingAttr(el, 'type')
const ifCondition = getAndRemoveAttr(el, 'v-if', true)
const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``
// 1. checkbox
const branch0 = cloneASTElement(el)
// process for on the main node
processFor(branch0)
addRawAttr(branch0, 'type', 'checkbox')
processElement(branch0, options)
branch0.processed = true // prevent it from double-processed
branch0.if = `type==='checkbox'` + (ifCondition ? `&&(${ifCondition})` : ``)
branch0.if = `type==='checkbox'` + ifConditionExtra
addIfCondition(branch0, {
exp: branch0.if,
block: branch0
Expand All @@ -46,7 +47,7 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
addRawAttr(branch1, 'type', 'radio')
processElement(branch1, options)
addIfCondition(branch0, {
exp: `type==='radio'` + (ifCondition ? `&&(${ifCondition})` : ``),
exp: `type==='radio'` + ifConditionExtra,
block: branch1
})
// 3. other
Expand Down

0 comments on commit 96b9744

Please sign in to comment.