|
|
@@ -8,10 +8,7 @@ import { def } from '../util/index'
|
|
|
const arrayProto = Array.prototype
|
|
|
export const arrayMethods = Object.create(arrayProto)
|
|
|
|
|
|
-/**
|
|
|
- * Intercept mutating methods and emit events
|
|
|
- */
|
|
|
-;[
|
|
|
+const methodsToPatch = [
|
|
|
'push',
|
|
|
'pop',
|
|
|
'shift',
|
|
|
@@ -19,7 +16,12 @@ export const arrayMethods = Object.create(arrayProto)
|
|
|
'splice',
|
|
|
'sort',
|
|
|
'reverse'
|
|
|
-].forEach(function (method) {
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * Intercept mutating methods and emit events
|
|
|
+ */
|
|
|
+methodsToPatch.forEach(function (method) {
|
|
|
// cache original method
|
|
|
const original = arrayProto[method]
|
|
|
def(arrayMethods, method, function mutator (...args) {
|