Evan You 11 лет назад
Родитель
Сommit
5a4cd1f493
4 измененных файлов с 10 добавлено и 8 удалено
  1. 0 2
      src/api/data.js
  2. 3 3
      src/directives/on.js
  3. 6 2
      src/directives/repeat.js
  4. 1 1
      src/observe/observer.js

+ 0 - 2
src/api/data.js

@@ -37,7 +37,6 @@ exports.$set = function (exp, val) {
 
 /**
  * Add a property on the VM
- * (and also on $scope and $data)
  *
  * @param {String} key
  * @param {*} val
@@ -51,7 +50,6 @@ exports.$add = function (key, val) {
 
 /**
  * Delete a property on the VM
- * (and also on $scope and $data)
  *
  * @param {String} key
  */

+ 3 - 3
src/directives/on.js

@@ -33,12 +33,12 @@ module.exports = {
     }
     this.reset()
     var vm = this.vm
-    var rootScope = vm.$root.$scope
+    var root = vm.$root
     this.handler = function (e) {
       e.targetVM = vm
-      rootScope.$event = e
+      root.$event = e
       var res = handler(e)
-      rootScope.$event = null
+      root.$event = null
       return res
     }
     if (this.iframeBind) {

+ 6 - 2
src/directives/repeat.js

@@ -268,8 +268,12 @@ module.exports = {
 
   resolveCtor: function (data) {
     var getter = expParser.parse(this.CtorExp).get
-    var context = Object.create(this.vm.$scope)
-    _.extend(context, data)
+    var context = Object.create(this.vm)
+    for (var key in data) {
+      // use _.define to avoid accidentally
+      // overwriting scope properties
+      _.define(context, key, data[key])
+    }
     var id = getter(context)
     return this.vm._asset('components', id) || _.Vue
   },

+ 1 - 1
src/observe/observer.js

@@ -84,7 +84,7 @@ Observer.create = function (value, options) {
     return new Observer(value, ARRAY, options)
   } else if (
     _.isObject(value) &&
-    !value.$scope // avoid Vue instance
+    !value.$observer // avoid Vue instance
   ) {
     return new Observer(value, OBJECT, options)
   }