2
0
Эх сурвалжийг харах

improve mutli-line `&&` coding style to keep consistence (#5625)

chengchao 9 жил өмнө
parent
commit
b5b1ac373a

+ 3 - 3
src/compiler/codegen/events.js

@@ -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.`

+ 4 - 3
src/compiler/codegen/index.js

@@ -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

+ 3 - 2
src/compiler/parser/html-parser.js

@@ -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.`
           )

+ 3 - 2
src/compiler/parser/index.js

@@ -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

+ 2 - 1
src/core/instance/index.js

@@ -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)

+ 2 - 1
src/core/instance/render-helpers/resolve-slots.js

@@ -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') {

+ 2 - 1
src/core/util/props.js

@@ -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

+ 2 - 1
src/core/vdom/create-element.js

@@ -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

+ 10 - 7
src/core/vdom/patch.js

@@ -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, '')
     }
   }
@@ -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
@@ -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)

+ 2 - 1
src/platforms/web/runtime/components/transition.js

@@ -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

+ 3 - 2
src/platforms/web/runtime/index.js

@@ -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` +

+ 2 - 1
src/platforms/web/runtime/modules/style.js

@@ -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
   }
 

+ 3 - 2
src/platforms/web/runtime/modules/transition.js

@@ -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)

+ 4 - 2
src/platforms/web/runtime/transition-util.js

@@ -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'
   }

+ 3 - 2
src/platforms/web/server/modules/dom-props.js

@@ -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])
       }
     }

+ 4 - 2
src/platforms/weex/runtime/modules/class.js

@@ -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
   }
 

+ 4 - 3
src/platforms/weex/runtime/modules/transition.js

@@ -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)

+ 3 - 2
src/server/render.js

@@ -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)) {