Prechádzať zdrojové kódy

config: remove proto option

Evan You 10 rokov pred
rodič
commit
539b107b79

+ 0 - 9
src/config.js

@@ -17,15 +17,6 @@ module.exports = {
 
 
   silent: false,
   silent: false,
 
 
-  /**
-   * Whether allow observer to alter data objects'
-   * __proto__.
-   *
-   * @type {Boolean}
-   */
-
-  proto: true,
-
   /**
   /**
    * Whether to use async rendering.
    * Whether to use async rendering.
    */
    */

+ 1 - 2
src/observer/index.js

@@ -1,5 +1,4 @@
 var _ = require('../util')
 var _ = require('../util')
-var config = require('../config')
 var Dep = require('./dep')
 var Dep = require('./dep')
 var arrayMethods = require('./array')
 var arrayMethods = require('./array')
 var arrayKeys = Object.getOwnPropertyNames(arrayMethods)
 var arrayKeys = Object.getOwnPropertyNames(arrayMethods)
@@ -19,7 +18,7 @@ function Observer (value) {
   this.dep = new Dep()
   this.dep = new Dep()
   _.define(value, '__ob__', this)
   _.define(value, '__ob__', this)
   if (_.isArray(value)) {
   if (_.isArray(value)) {
-    var augment = config.proto && _.hasProto
+    var augment = _.hasProto
       ? protoAugment
       ? protoAugment
       : copyAugment
       : copyAugment
     augment(value, arrayMethods, arrayKeys)
     augment(value, arrayMethods, arrayKeys)

+ 2 - 3
test/unit/specs/observer/observer_spec.js

@@ -1,6 +1,5 @@
 var Observer = require('../../../../src/observer')
 var Observer = require('../../../../src/observer')
 var Dep = require('../../../../src/observer/dep')
 var Dep = require('../../../../src/observer/dep')
-var config = require('../../../../src/config')
 var _ = require('../../../../src/util')
 var _ = require('../../../../src/util')
 
 
 describe('Observer', function () {
 describe('Observer', function () {
@@ -165,7 +164,7 @@ describe('Observer', function () {
   })
   })
 
 
   it('no proto', function () {
   it('no proto', function () {
-    config.proto = false
+    _.hasProto = false
     var arr = [1, 2, 3]
     var arr = [1, 2, 3]
     var ob2 = Observer.create(arr)
     var ob2 = Observer.create(arr)
     expect(arr.$set).toBeTruthy()
     expect(arr.$set).toBeTruthy()
@@ -175,7 +174,7 @@ describe('Observer', function () {
     spyOn(dep2, 'notify')
     spyOn(dep2, 'notify')
     arr.push(1)
     arr.push(1)
     expect(dep2.notify).toHaveBeenCalled()
     expect(dep2.notify).toHaveBeenCalled()
-    config.proto = true
+    _.hasProto = true
   })
   })
 
 
 })
 })