Skip to content

Commit

Permalink
improve mutli-line && coding style to keep consistence (#5625)
Browse files Browse the repository at this point in the history
  • Loading branch information
defcc authored and yyx990803 committed May 9, 2017
1 parent 1c40e32 commit b5b1ac3
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 38 deletions.
6 changes: 3 additions & 3 deletions src/compiler/codegen/events.js
Expand Up @@ -44,9 +44,9 @@ export function genHandlers (
const handler = events[name]
// #5330: warn click.right, since right clicks do not actually fire click events.
if (process.env.NODE_ENV !== 'production' &&
name === 'click' &&
handler && handler.modifiers && handler.modifiers.right
) {
name === 'click' &&
handler && handler.modifiers && handler.modifiers.right
) {
warn(
`Use "contextmenu" instead of "click.right" since right clicks ` +
`do not actually fire "click" events.`
Expand Down
7 changes: 4 additions & 3 deletions src/compiler/codegen/index.js
Expand Up @@ -311,9 +311,10 @@ function genChildren (el: ASTElement, checkSkip?: boolean): string | void {
const el: any = children[0]
// optimize single v-for
if (children.length === 1 &&
el.for &&
el.tag !== 'template' &&
el.tag !== 'slot') {
el.for &&
el.tag !== 'template' &&
el.tag !== 'slot'
) {
return genElement(el)
}
const normalizationType = checkSkip ? getNormalizationType(children) : 0
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/parser/html-parser.js
Expand Up @@ -279,8 +279,9 @@ export function parseHTML (html, options) {
// Close all the open elements, up the stack
for (let i = stack.length - 1; i >= pos; i--) {
if (process.env.NODE_ENV !== 'production' &&
(i > pos || !tagName) &&
options.warn) {
(i > pos || !tagName) &&
options.warn
) {
options.warn(
`tag <${stack[i].tag}> has no matching end tag.`
)
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/parser/index.js
Expand Up @@ -246,8 +246,9 @@ export function parse (
// IE textarea placeholder bug
/* istanbul ignore if */
if (isIE &&
currentParent.tag === 'textarea' &&
currentParent.attrsMap.placeholder === text) {
currentParent.tag === 'textarea' &&
currentParent.attrsMap.placeholder === text
) {
return
}
const children = currentParent.children
Expand Down
3 changes: 2 additions & 1 deletion src/core/instance/index.js
Expand Up @@ -7,7 +7,8 @@ import { warn } from '../util/index'

function Vue (options) {
if (process.env.NODE_ENV !== 'production' &&
!(this instanceof Vue)) {
!(this instanceof Vue)
) {
warn('Vue is a constructor and should be called with the `new` keyword')
}
this._init(options)
Expand Down
3 changes: 2 additions & 1 deletion src/core/instance/render-helpers/resolve-slots.js
Expand Up @@ -17,7 +17,8 @@ export function resolveSlots (
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null) {
child.data && child.data.slot != null
) {
const name = child.data.slot
const slot = (slots[name] || (slots[name] = []))
if (child.tag === 'template') {
Expand Down
3 changes: 2 additions & 1 deletion src/core/util/props.js
Expand Up @@ -66,7 +66,8 @@ function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): a
// return previous default value to avoid unnecessary watcher trigger
if (vm && vm.$options.propsData &&
vm.$options.propsData[key] === undefined &&
vm._props[key] !== undefined) {
vm._props[key] !== undefined
) {
return vm._props[key]
}
// call factory function for non-Function types
Expand Down
3 changes: 2 additions & 1 deletion src/core/vdom/create-element.js
Expand Up @@ -63,7 +63,8 @@ export function _createElement (
}
// support single function children as default scoped slot
if (Array.isArray(children) &&
typeof children[0] === 'function') {
typeof children[0] === 'function'
) {
data = data || {}
data.scopedSlots = { default: children[0] }
children.length = 0
Expand Down
17 changes: 10 additions & 7 deletions src/core/vdom/patch.js
Expand Up @@ -285,8 +285,9 @@ export function createPatchFunction (backend) {
}
// for slot content they should also get the scopeId from the host instance.
if (isDef(i = activeInstance) &&
i !== vnode.context &&
isDef(i = i.$options._scopeId)) {
i !== vnode.context &&
isDef(i = i.$options._scopeId)
) {
nodeOps.setAttribute(vnode.elm, i, '')
}
}
Expand Down Expand Up @@ -438,9 +439,10 @@ export function createPatchFunction (backend) {
// if the new node is not cloned it means the render functions have been
// reset by the hot-reload-api and we need to do a proper re-render.
if (isTrue(vnode.isStatic) &&
isTrue(oldVnode.isStatic) &&
vnode.key === oldVnode.key &&
(isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
isTrue(oldVnode.isStatic) &&
vnode.key === oldVnode.key &&
(isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
) {
vnode.elm = oldVnode.elm
vnode.componentInstance = oldVnode.componentInstance
return
Expand Down Expand Up @@ -529,8 +531,9 @@ export function createPatchFunction (backend) {
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed) {
typeof console !== 'undefined' &&
!bailed
) {
bailed = true
console.warn('Parent: ', elm)
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children)
Expand Down
3 changes: 2 additions & 1 deletion src/platforms/web/runtime/components/transition.js
Expand Up @@ -103,7 +103,8 @@ export default {

// warn invalid mode
if (process.env.NODE_ENV !== 'production' &&
mode && mode !== 'in-out' && mode !== 'out-in') {
mode && mode !== 'in-out' && mode !== 'out-in'
) {
warn(
'invalid <transition> mode: ' + mode,
this.$parent
Expand Down
5 changes: 3 additions & 2 deletions src/platforms/web/runtime/index.js
Expand Up @@ -56,8 +56,9 @@ setTimeout(() => {
}
}
if (process.env.NODE_ENV !== 'production' &&
config.productionTip !== false &&
inBrowser && typeof console !== 'undefined') {
config.productionTip !== false &&
inBrowser && typeof console !== 'undefined'
) {
console[console.info ? 'info' : 'log'](
`You are running Vue in development mode.\n` +
`Make sure to turn on production mode when deploying for production.\n` +
Expand Down
3 changes: 2 additions & 1 deletion src/platforms/web/runtime/modules/style.js
Expand Up @@ -49,7 +49,8 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
const oldData = oldVnode.data

if (isUndef(data.staticStyle) && isUndef(data.style) &&
isUndef(oldData.staticStyle) && isUndef(oldData.style)) {
isUndef(oldData.staticStyle) && isUndef(oldData.style)
) {
return
}

Expand Down
5 changes: 3 additions & 2 deletions src/platforms/web/runtime/modules/transition.js
Expand Up @@ -134,8 +134,9 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
const parent = el.parentNode
const pendingNode = parent && parent._pending && parent._pending[vnode.key]
if (pendingNode &&
pendingNode.tag === vnode.tag &&
pendingNode.elm._leaveCb) {
pendingNode.tag === vnode.tag &&
pendingNode.elm._leaveCb
) {
pendingNode.elm._leaveCb()
}
enterHook && enterHook(el, cb)
Expand Down
6 changes: 4 additions & 2 deletions src/platforms/web/runtime/transition-util.js
Expand Up @@ -44,12 +44,14 @@ export let animationEndEvent = 'animationend'
if (hasTransition) {
/* istanbul ignore if */
if (window.ontransitionend === undefined &&
window.onwebkittransitionend !== undefined) {
window.onwebkittransitionend !== undefined
) {
transitionProp = 'WebkitTransition'
transitionEndEvent = 'webkitTransitionEnd'
}
if (window.onanimationend === undefined &&
window.onwebkitanimationend !== undefined) {
window.onwebkitanimationend !== undefined
) {
animationProp = 'WebkitAnimation'
animationEndEvent = 'webkitAnimationEnd'
}
Expand Down
5 changes: 3 additions & 2 deletions src/platforms/web/server/modules/dom-props.js
Expand Up @@ -30,8 +30,9 @@ export default function renderDOMProps (node: VNodeWithData): string {
} else {
const attr = propsToAttrMap[key] || key.toLowerCase()
if (isRenderableAttr(attr) &&
// avoid rendering double-bound props/attrs twice
!(isDef(attrs) && isDef(attrs[attr]))) {
// avoid rendering double-bound props/attrs twice
!(isDef(attrs) && isDef(attrs[attr]))
) {
res += renderAttr(attr, props[key])
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/platforms/weex/runtime/modules/class.js
Expand Up @@ -8,8 +8,10 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {

const data: VNodeData = vnode.data
const oldData: VNodeData = oldVnode.data
if (!data.staticClass && !data.class &&
(!oldData || (!oldData.staticClass && !oldData.class))) {
if (!data.staticClass &&
!data.class &&
(!oldData || (!oldData.staticClass && !oldData.class))
) {
return
}

Expand Down
7 changes: 4 additions & 3 deletions src/platforms/weex/runtime/modules/transition.js
Expand Up @@ -94,9 +94,10 @@ function enter (_, vnode) {
const parent = el.parentNode
const pendingNode = parent && parent._pending && parent._pending[vnode.key]
if (pendingNode &&
pendingNode.context === vnode.context &&
pendingNode.tag === vnode.tag &&
pendingNode.elm._leaveCb) {
pendingNode.context === vnode.context &&
pendingNode.tag === vnode.tag &&
pendingNode.elm._leaveCb
) {
pendingNode.elm._leaveCb()
}
enterHook && enterHook(el, cb)
Expand Down
5 changes: 3 additions & 2 deletions src/server/render.js
Expand Up @@ -255,8 +255,9 @@ function renderStartingTag (node: VNode, context) {
let scopeId
const activeInstance = context.activeInstance
if (isDef(activeInstance) &&
activeInstance !== node.context &&
isDef(scopeId = activeInstance.$options._scopeId)) {
activeInstance !== node.context &&
isDef(scopeId = activeInstance.$options._scopeId)
) {
markup += ` ${(scopeId: any)}`
}
while (isDef(node)) {
Expand Down

0 comments on commit b5b1ac3

Please sign in to comment.