Pārlūkot izejas kodu

refactor: empty function replace to noop (#8791)

JJJ 7 gadi atpakaļ
vecāks
revīzija
4f111f9225
2 mainītis faili ar 5 papildinājumiem un 4 dzēšanām
  1. 3 2
      src/core/observer/watcher.js
  2. 2 2
      src/platforms/weex/util/element.js

+ 3 - 2
src/core/observer/watcher.js

@@ -6,7 +6,8 @@ import {
   isObject,
   parsePath,
   _Set as Set,
-  handleError
+  handleError,
+  noop
 } from '../util/index'
 
 import { traverse } from './traverse'
@@ -80,7 +81,7 @@ export default class Watcher {
     } else {
       this.getter = parsePath(expOrFn)
       if (!this.getter) {
-        this.getter = function () {}
+        this.getter = noop
         process.env.NODE_ENV !== 'production' && warn(
           `Failed watching path: "${expOrFn}" ` +
           'Watcher only accepts simple dot-delimited paths. ' +

+ 2 - 2
src/platforms/weex/util/element.js

@@ -4,7 +4,7 @@
 // makeMap() due to potential side effects, so these variables end up
 // bloating the web builds.
 
-import { makeMap } from 'shared/util'
+import { makeMap, noop } from 'shared/util'
 
 export const isReservedTag = makeMap(
   'template,script,style,element,content,slot,link,meta,svg,view,' +
@@ -46,7 +46,7 @@ export function isUnknownElement (tag?: string): boolean {
 export function query (el: string | Element, document: Object) {
   // document is injected by weex factory wrapper
   const placeholder = document.createComment('root')
-  placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
+  placeholder.hasAttribute = placeholder.removeAttribute = noop // hack for patch
   document.documentElement.appendChild(placeholder)
   return placeholder
 }