Skip to content

Commit 1bcc571

Browse files
committed
Revert "fix #4041, warn overriding Vue's internal methods (#4111)"
This reverts commit 4078ce9.
1 parent eb601ad commit 1bcc571

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

Diff for: src/core/instance/state.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {
2121
noop
2222
} from '../util/index'
2323

24-
import BuiltinVue from '../index'
25-
2624
export function initState (vm: Component) {
2725
vm._watchers = []
2826
initProps(vm)
@@ -145,16 +143,12 @@ function initMethods (vm: Component) {
145143
if (methods) {
146144
for (const key in methods) {
147145
vm[key] = methods[key] == null ? noop : bind(methods[key], vm)
148-
if (process.env.NODE_ENV !== 'production') {
149-
methods[key] == null && warn(
146+
if (process.env.NODE_ENV !== 'production' && methods[key] == null) {
147+
warn(
150148
`method "${key}" has an undefined value in the component definition. ` +
151149
`Did you reference the function correctly?`,
152150
vm
153151
)
154-
hasOwn(BuiltinVue.prototype, key) && warn(
155-
`Avoid overriding Vue's internal method "${key}".`,
156-
vm
157-
)
158152
}
159153
}
160154
}

Diff for: test/unit/features/options/methods.spec.js

-10
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,4 @@ describe('Options methods', () => {
2424
})
2525
expect(`method "hello" has an undefined value in the component definition`).toHaveBeenWarned()
2626
})
27-
28-
it('should warn overriding builtin methods', () => {
29-
new Vue({
30-
methods: {
31-
$emit () {
32-
}
33-
}
34-
})
35-
expect(`Avoid overriding Vue's internal method "$emit".`).toHaveBeenWarned()
36-
})
3727
})

0 commit comments

Comments
 (0)