Skip to content

Commit 4f111f9

Browse files
jessejyangyyx990803
authored andcommitted
refactor: empty function replace to noop (vuejs#8791)
1 parent 390ff8e commit 4f111f9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/core/observer/watcher.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
isObject,
77
parsePath,
88
_Set as Set,
9-
handleError
9+
handleError,
10+
noop
1011
} from '../util/index'
1112

1213
import { traverse } from './traverse'
@@ -80,7 +81,7 @@ export default class Watcher {
8081
} else {
8182
this.getter = parsePath(expOrFn)
8283
if (!this.getter) {
83-
this.getter = function () {}
84+
this.getter = noop
8485
process.env.NODE_ENV !== 'production' && warn(
8586
`Failed watching path: "${expOrFn}" ` +
8687
'Watcher only accepts simple dot-delimited paths. ' +

src/platforms/weex/util/element.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// makeMap() due to potential side effects, so these variables end up
55
// bloating the web builds.
66

7-
import { makeMap } from 'shared/util'
7+
import { makeMap, noop } from 'shared/util'
88

99
export const isReservedTag = makeMap(
1010
'template,script,style,element,content,slot,link,meta,svg,view,' +
@@ -46,7 +46,7 @@ export function isUnknownElement (tag?: string): boolean {
4646
export function query (el: string | Element, document: Object) {
4747
// document is injected by weex factory wrapper
4848
const placeholder = document.createComment('root')
49-
placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
49+
placeholder.hasAttribute = placeholder.removeAttribute = noop // hack for patch
5050
document.documentElement.appendChild(placeholder)
5151
return placeholder
5252
}

0 commit comments

Comments
 (0)