Pārlūkot izejas kodu

API change: split `scope` into `data` and `methods`

Evan You 12 gadi atpakaļ
vecāks
revīzija
7c1d196355

+ 5 - 3
examples/firebase/app.js

@@ -20,7 +20,7 @@ Users.on('child_removed', function (snapshot) {
 var app = new Vue({
     el: '#app',
     filters: validators,
-    scope: {
+    data: {
         users: [],
         newUser: {
             name: '',
@@ -40,7 +40,9 @@ var app = new Vue({
                 }
                 return valid
             }
-        },
+        }
+    },
+    methods: {
         addUser: function (e) {
             e.preventDefault()
             if (this.isValid) {
@@ -49,7 +51,7 @@ var app = new Vue({
             }
         },
         removeUser: function (e) {
-            new Firebase(baseURL + 'users/' + e.item.id).remove()
+            new Firebase(baseURL + 'users/' + e.targetVM.id).remove()
         }
     }
 })

+ 2 - 2
examples/firebase/index.html

@@ -10,8 +10,8 @@
     <body>
         <div id="app">
             <ul>
-                <li class="user" v-repeat="user:users" v-transition>
-                    <span>{{user.name}} - {{user.email}}</span>
+                <li class="user" v-repeat="users" v-transition>
+                    <span>{{name}} - {{email}}</span>
                     <button v-on="click:removeUser">X</button>
                 </li>
             </ul>

+ 17 - 15
examples/todomvc/js/app.js

@@ -24,10 +24,25 @@ var app = new Vue({
         }).length
     },
 
-    scope: {
+    data: {
 
         todos: todoStorage.fetch(),
 
+        allDone: {
+            $get: function () {
+                return this.remaining === 0
+            },
+            $set: function (value) {
+                this.todos.forEach(function (todo) {
+                    todo.completed = value
+                })
+                this.remaining = value ? 0 : this.todos.length
+                todoStorage.save()
+            }
+        }
+    },
+
+    methods: {
         updateFilter: function () {
             var filter = location.hash.slice(2)
             this.filter = (filter in filters) ? filter : 'all'
@@ -45,7 +60,7 @@ var app = new Vue({
         },
 
         removeTodo: function (e) {
-            this.todos.remove(e.targetVM.$scope)
+            this.todos.remove(e.targetVM.$data)
             this.remaining -= e.targetVM.completed ? 0 : 1
             todoStorage.save()
         },
@@ -78,19 +93,6 @@ var app = new Vue({
                 return todo.completed
             })
             todoStorage.save()
-        },
-
-        allDone: {
-            $get: function () {
-                return this.remaining === 0
-            },
-            $set: function (value) {
-                this.todos.forEach(function (todo) {
-                    todo.completed = value
-                })
-                this.remaining = value ? 0 : this.todos.length
-                todoStorage.save()
-            }
         }
     }
 })

+ 28 - 29
src/compiler.js

@@ -13,6 +13,7 @@ var Emitter     = require('./emitter'),
     slice       = Array.prototype.slice,
     log         = utils.log,
     makeHash    = utils.hash,
+    extend      = utils.extend,
     def         = utils.defProtected,
     hasOwn      = Object.prototype.hasOwnProperty
 
@@ -30,21 +31,20 @@ function Compiler (vm, options) {
 
     // process and extend options
     options = compiler.options = options || makeHash()
+    var data = compiler.data = options.data || {}
     utils.processOptions(options)
-    utils.extend(compiler, options.compilerOptions)
+    extend(compiler, options.compilerOptions)
+    extend(vm, options.data, true)
+    extend(vm, options.methods, true)
 
     // initialize element
     var el = compiler.setupElement(options)
     log('\nnew VM instance:', el.tagName, '\n')
 
-    // init scope
-    var scope = compiler.scope = options.scope || {}
-    utils.extend(vm, scope, true)
-
     compiler.vm  = vm
     def(vm, '$', makeHash())
     def(vm, '$el', el)
-    def(vm, '$scope', scope)
+    def(vm, '$data', data)
     def(vm, '$compiler', compiler)
 
     // keep track of directives and expressions
@@ -87,16 +87,16 @@ function Compiler (vm, options) {
     // beforeCompile hook
     compiler.execHook('beforeCompile', 'created')
     // the user might have set some props on the vm 
-    // so copy it back to the scope...
-    utils.extend(scope, vm)
-    // observe the scope
-    Observer.observe(scope, '', compiler.observer)
+    // so copy it back to the data...
+    extend(data, vm)
+    // observe the data
+    Observer.observe(data, '', compiler.observer)
 
     // for repeated items, create an index binding
     // which should be inenumerable but configurable
     if (compiler.repeat) {
-        //scope.$index = compiler.repeatIndex
-        def(scope, '$index', compiler.repeatIndex, false, true)
+        //data.$index = compiler.repeatIndex
+        def(data, '$index', compiler.repeatIndex, false, true)
         compiler.createBinding('$index')
     }
 
@@ -369,7 +369,7 @@ CompilerProto.bindDirective = function (directive) {
         // expression bindings are always created on current compiler
         binding = compiler.createBinding(key, true, directive.isFn)
     } else if (
-        hasOwn.call(compiler.scope, baseKey) ||
+        hasOwn.call(compiler.data, baseKey) ||
         hasOwn.call(compiler.vm, baseKey)
     ) {
         // If the directive's compiler's VM has the base key,
@@ -409,7 +409,7 @@ CompilerProto.bindDirective = function (directive) {
 CompilerProto.createBinding = function (key, isExp, isFn) {
 
     var compiler = this,
-        scope = compiler.scope,
+        data = compiler.data,
         bindings = compiler.bindings,
         binding  = new Binding(compiler, key, isExp, isFn)
 
@@ -434,8 +434,8 @@ CompilerProto.createBinding = function (key, isExp, isFn) {
             // this is a root level binding. we need to define getter/setters for it.
             compiler.define(key, binding)
         } else {
-            // ensure path in scope so it can be observed
-            Observer.ensurePath(scope, key)
+            // ensure path in data so it can be observed
+            Observer.ensurePath(data, key)
             var parentKey = key.slice(0, key.lastIndexOf('.'))
             if (!hasOwn.call(bindings, parentKey)) {
                 // this is a nested value binding, but the binding for its parent
@@ -456,41 +456,40 @@ CompilerProto.define = function (key, binding) {
     log('    defined root binding: ' + key)
 
     var compiler = this,
-        scope = compiler.scope,
+        data = compiler.data,
         vm = compiler.vm,
-        value = binding.value = scope[key] // save the value before redefinening it
+        value = binding.value = data[key] // save the value before redefinening it
 
     if (utils.typeOf(value) === 'Object' && value.$get) {
         compiler.markComputed(binding)
     }
 
-    // $index is inenumerable
-    if (!(key in scope) && key !== '$index') {
-        scope[key] = undefined
+    if (!(key in data)) {
+        data[key] = undefined
     }
 
-    // if the scope object is already observed, that means
+    // if the data object is already observed, that means
     // this binding is created late. we need to observe it now.
-    if (scope.__observer__) {
-        Observer.convert(scope, key)
+    if (data.__observer__) {
+        Observer.convert(data, key)
     }
 
     Object.defineProperty(vm, key, {
         get: binding.isComputed
             ? function () {
-                return scope[key].$get()
+                return data[key].$get()
             }
             : function () {
-                return scope[key]
+                return data[key]
             },
         set: binding.isComputed
             ? function (val) {
-                if (scope[key].$set) {
-                    scope[key].$set(val)
+                if (data[key].$set) {
+                    data[key].$set(val)
                 }
             }
             : function (val) {
-                scope[key] = val
+                data[key] = val
             }
     })
 }

+ 1 - 1
src/directives/component.js

@@ -21,7 +21,7 @@ module.exports = {
         if (!Ctor) utils.warn('unknown component: ' + this.arg)
         var options = {
             el: this.el,
-            scope: value,
+            data: value,
             compilerOptions: {
                 parentCompiler: this.compiler
             }

+ 3 - 3
src/directives/repeat.js

@@ -60,7 +60,7 @@ var mutationHandlers = {
             data = col[i]
             for (j = 0; j < l; j++) {
                 vm = vms[j]
-                if (vm.$scope === data) {
+                if (vm.$data === data) {
                     sorted[i] = vm
                     break
                 }
@@ -171,7 +171,7 @@ module.exports = {
 
         item = new this.ChildVM({
             el: node,
-            scope: data,
+            data: data,
             compilerOptions: {
                 repeat: true,
                 repeatIndex: index,
@@ -196,7 +196,7 @@ module.exports = {
     updateIndexes: function () {
         var i = this.vms.length
         while (i--) {
-            this.vms[i].$scope.$index = i
+            this.vms[i].$data.$index = i
         }
     },
 

+ 2 - 2
src/exp-parser.js

@@ -59,7 +59,7 @@ function getRel (path, compiler) {
             : path
     while (true) {
         if (
-            hasOwn.call(vm.$scope, key) ||
+            hasOwn.call(vm.$data, key) ||
             hasOwn.call(vm, key)
         ) {
             break
@@ -85,7 +85,7 @@ function getRel (path, compiler) {
 /**
  *  Create a function from a string...
  *  this looks like evil magic but since all variables are limited
- *  to the VM's scope it's actually properly sandboxed
+ *  to the VM's data it's actually properly sandboxed
  */
 function makeGetter (exp, raw) {
     /* jshint evil: true */

+ 10 - 7
src/main.js

@@ -86,11 +86,14 @@ function extend (options) {
     utils.defProtected(proto, 'constructor', ExtendedVM)
 
     // copy prototype props
-    var protoMixins = options.proto
-    if (protoMixins) {
-        for (var key in protoMixins) {
-            if (!(key in ViewModel.prototype)) {
-                proto[key] = protoMixins[key]
+    var methods = options.methods
+    if (methods) {
+        for (var key in methods) {
+            if (
+                !(key in ViewModel.prototype) &&
+                typeof methods[key] === 'function'
+            ) {
+                proto[key] = methods[key]
             }
         }
     }
@@ -105,7 +108,7 @@ function extend (options) {
 /**
  *  Inherit options
  *
- *  For options such as `scope`, `vms`, `directives`, 'partials',
+ *  For options such as `data`, `vms`, `directives`, 'partials',
  *  they should be further extended. However extending should only
  *  be done at top level.
  *  
@@ -119,7 +122,7 @@ function inheritOptions (child, parent, topLevel) {
     child = child || utils.hash()
     if (!parent) return child
     for (var key in parent) {
-        if (key === 'el' || key === 'proto') continue
+        if (key === 'el' || key === 'methods') continue
         var val = child[key],
             parentVal = parent[key],
             type = utils.typeOf(val)

+ 3 - 3
test/functional/fixtures/expression.html

@@ -27,7 +27,7 @@
         Vue.config({debug:true})
             var normal = new Vue({
                 el: '#normal',
-                scope: {
+                data: {
                     one: 'Hello',
                     two: {
                         three: 'World'
@@ -38,7 +38,7 @@
             var lazy = new Vue({
                 el: '#lazy',
                 lazy: true,
-                scope: {
+                data: {
                     one: 'Hi',
                     two: {
                         three: 'Ho'
@@ -48,7 +48,7 @@
 
             var conditional = new Vue({
                 el: '#conditional',
-                scope: {
+                data: {
                     ok: true,
                     yesMsg: 'YES',
                     noMsg: 'NO'

+ 3 - 3
test/functional/fixtures/extend.html

@@ -29,12 +29,12 @@
                 },
                 components: {
                     'vm-test': {
-                        scope: {
+                        data: {
                             vmMsg: 'component works'
                         }
                     },
                     'vm-w-model': {
-                        scope : {
+                        data : {
                             selfMsg: 'component with model '
                         }
                     }
@@ -63,7 +63,7 @@
             })
             new T({
                 el: '#test',
-                scope: {
+                data: {
                     dirMsg: 'directive',
                     filterMsg: 'fi43l132ter5 w12345orks',
                     partialMsg: 'partial works',

+ 1 - 1
test/functional/fixtures/forms.html

@@ -36,7 +36,7 @@
             var test = new Vue({
                 el: 'body',
                 lazy: true,
-                scope: {
+                data: {
                     text: 'some text',
                     checked: true,
                     radio: 'b',

+ 17 - 15
test/functional/fixtures/nested-props.html

@@ -28,7 +28,23 @@
                     this.msg = 'Yoyoyo'
                     this.a = data
                 },
-                proto: {
+                data: {
+                    d: {
+                        $get: function () {
+                            return this.msg + (this.a.b.c || '') + (this.a.c || '')
+                        }
+                    },
+                    hidden: {
+                        a: 1,
+                        b: 2
+                    },
+                    sum: {
+                        $get: function () {
+                            return this.hidden.a + this.hidden.b
+                        }
+                    }
+                },
+                methods: {
                     one: function () {
                         this.a = {
                             c: 1,
@@ -47,20 +63,6 @@
                         this.a.b.c = 'three'
                         this.a.c = 3
                     },
-                    d: {
-                        $get: function () {
-                            return this.msg + (this.a.b.c || '') + (this.a.c || '')
-                        }
-                    },
-                    hidden: {
-                        a: 1,
-                        b: 2
-                    },
-                    sum: {
-                        $get: function () {
-                            return this.hidden.a + this.hidden.b
-                        }
-                    },
                     four: function () {
                         this.hidden.a++
                     },

+ 1 - 1
test/functional/fixtures/nested-repeat.html

@@ -31,7 +31,7 @@
         ]
         new Vue({
             el: '#test',
-            scope: {
+            data: {
                 items: items
             }
         })

+ 1 - 1
test/functional/fixtures/repeated-items.html

@@ -37,7 +37,7 @@
 
             var demo = new Vue({
                 el: '#app',
-                scope: {
+                data: {
                     items: items,
                     push: function () {
                         this.items.push({ title: getChar() })

+ 3 - 3
test/functional/fixtures/repeated-vms.html

@@ -16,19 +16,19 @@
                 ready: function () {
                     this.title += ' init'
                 },
-                proto: {
+                methods: {
                     click: function () {
                         this.title += ' click'
                     }
                 },
-                scope: {
+                data: {
                     msg: 'msg'
                 }
             })
 
             new Vue({
                 el: 'body',
-                scope: {
+                data: {
                     items: [
                         {title:'a'},
                         {title:'b'},

+ 4 - 4
test/functional/fixtures/share-data.html

@@ -21,26 +21,26 @@
             }
             new Vue({
                 el: '#a',
-                scope: {
+                data: {
                     shared: shared
                 }
             })
             new Vue({
                 el: '#b',
-                scope: {
+                data: {
                     shared: shared
                 }
             })
             new Vue({
                 lazy: true,
                 el: '#c',
-                scope: {
+                data: {
                     shared: shared
                 }
             })
             new Vue({
                 el: '#d',
-                scope: {
+                data: {
                     shared: shared,
                     source: {
                         $get: function () {

+ 1 - 1
test/functional/fixtures/transition.html

@@ -62,7 +62,7 @@
         <script>
             var test = new Vue({
                 el: '#test',
-                scope: {
+                data: {
                     b: 1,
                     set: function (e) {
                         this.b = +e.el.textContent

+ 1 - 1
test/functional/fixtures/validation.html

@@ -24,7 +24,7 @@
                         return val
                     }
                 },
-                scope: {
+                data: {
                     a: 'hihi',
                     validation: {
                         email: true

+ 1 - 1
test/functional/specs/nested-props.js

@@ -27,7 +27,7 @@ casper.test.begin('Nested Properties', 20, function (test) {
         })
         test.assertSelectorHasText('h3 span', 'Oh yeah three3')
 
-        // hidden scope variables
+        // hidden data variables
         // i.e. nested under an object, not explicitly
         // bound in the template, but is depended upon
         // by an expression or a computed property

+ 31 - 32
test/unit/specs/api.js

@@ -10,7 +10,7 @@ describe('UNIT: API', function () {
             mock(testId, '<span test-text="test"></span>')
             new Vue({
                 el: '#' + testId,
-                scope: { test: testId }
+                data: { test: testId }
             })
             assert.strictEqual(document.querySelector('#' + testId + ' span').innerHTML, testId)
         })
@@ -36,7 +36,7 @@ describe('UNIT: API', function () {
             mock(testId, '{{ test | reverse }}')
             new Vue({
                 el: '#' + testId,
-                scope: { test: msg }
+                data: { test: msg }
             })
             assert.strictEqual(document.querySelector('#' + testId).innerHTML, '54321')
         })
@@ -61,7 +61,7 @@ describe('UNIT: API', function () {
             mock(testId, '<span v-test="test"></span>')
             new Vue({
                 el: '#' + testId,
-                scope: { test: msg }
+                data: { test: msg }
             })
             var el = document.querySelector('#' + testId + ' span')
             assert.strictEqual(el.getAttribute(testId), msg + '123')
@@ -85,7 +85,7 @@ describe('UNIT: API', function () {
             mock(testId, '<span v-test2="test"></span>')
             var vm = new Vue({
                     el: '#' + testId,
-                    scope: { test: msg }
+                    data: { test: msg }
                 }),
                 el = document.querySelector('#' + testId + ' span')
             assert.strictEqual(el.getAttribute(testId + 'bind'), 'bind', 'should have called bind()')
@@ -107,7 +107,7 @@ describe('UNIT: API', function () {
             testId2 = testId + '2',
             opts = {
                 className: 'hihi',
-                scope: { hi: 'ok' }
+                data: { hi: 'ok' }
             },
             Test = Vue.extend(opts),
             utils = require('vue/src/utils')
@@ -167,7 +167,7 @@ describe('UNIT: API', function () {
             mock(testId, '<div class="directive" v-partial="' + testId + '">hello</div>')
             var t = new Vue({
                 el: '#' + testId,
-                scope: { hi: 'hohoho' }
+                data: { hi: 'hohoho' }
             })
             assert.strictEqual(t.$el.querySelector('.directive .partial-test a').textContent, 'hohoho')
             assert.strictEqual(t.$el.querySelector('.directive span').innerHTML, 'hahaha')
@@ -179,7 +179,7 @@ describe('UNIT: API', function () {
             mock(testId, '<div class="inline">{{>' + testId + '}}</div>')
             var t = new Vue({
                 el: '#' + testId,
-                scope: { hi: 'hohoho' }
+                data: { hi: 'hohoho' }
             })
             assert.strictEqual(t.$el.querySelector('.inline .partial-test a').textContent, 'hohoho')
             assert.strictEqual(t.$el.querySelector('.inline span').innerHTML, 'hahaha')
@@ -222,7 +222,7 @@ describe('UNIT: API', function () {
                     'v-show': 'show',
                     'v-transition': 'transition-api-test'
                 },
-                scope: {
+                data: {
                     show: false
                 }
             })
@@ -251,12 +251,12 @@ describe('UNIT: API', function () {
 
         it('should allow further extensions', function () {
             var Parent = Vue.extend({
-                scope: {
+                data: {
                     test: 'hi'
                 }
             })
             var Child = Parent.extend({
-                scope: {
+                data: {
                     test2: 'ho',
                     test3: {
                         hi: 1
@@ -265,7 +265,7 @@ describe('UNIT: API', function () {
             })
             assert.strictEqual(Child.super, Parent)
             var child = new Child({
-                scope: {
+                data: {
                     test3: {
                         ho: 2
                     }
@@ -280,15 +280,14 @@ describe('UNIT: API', function () {
 
         describe('Options', function () {
 
-            describe('proto', function () {
+            describe('methods', function () {
                 
                 it('should be mixed to the exteded VM\'s prototype', function () {
                     var mixins = {
-                        a: 1,
-                        b: 2,
-                        c: function () {}
+                        c: function () {},
+                        d: function () {}
                     }
-                    var Test = Vue.extend({ proto: mixins })
+                    var Test = Vue.extend({ methods: mixins })
                     for (var key in mixins) {
                         assert.strictEqual(Test.prototype[key], mixins[key])
                     }
@@ -296,12 +295,12 @@ describe('UNIT: API', function () {
 
             })
 
-            describe('scope', function () {
+            describe('data', function () {
                 
                 it('should be copied to each instance', function () {
                     var testData = { a: 1 },
                         Test = Vue.extend({
-                            scope: {
+                            data: {
                                 test: testData
                             }
                         })
@@ -323,7 +322,7 @@ describe('UNIT: API', function () {
                         lazy: true
                     })
                     var t = new Test({
-                        scope: {
+                        data: {
                             test: 'hi'
                         }
                     })
@@ -398,7 +397,7 @@ describe('UNIT: API', function () {
                             'test': 'hi',
                             'v-text': 'hoho'
                         },
-                        scope: {
+                        data: {
                             hoho: 'what'
                         }
                     })
@@ -420,7 +419,7 @@ describe('UNIT: API', function () {
                                 'test': 'hi',
                                 'v-text': 'hoho'
                             },
-                            scope: {
+                            data: {
                                 hoho: 'what'
                             }
                         }),
@@ -445,7 +444,7 @@ describe('UNIT: API', function () {
                     var Test = Vue.extend({
                             tagName: 'p',
                             template: raw,
-                            scope: {
+                            data: {
                                 hello: 'Ahaha'
                             }
                         }),
@@ -466,7 +465,7 @@ describe('UNIT: API', function () {
                     document.getElementById('test').appendChild(tpl)
                     var Test = Vue.extend({
                         template: '#' + testId,
-                        scope: { hello: testId }
+                        data: { hello: testId }
                     })
                     var t = new Test()
                     assert.strictEqual(t.$el.querySelector('span').textContent, testId)
@@ -478,7 +477,7 @@ describe('UNIT: API', function () {
                     })
                     var t = new Test({
                         template: raw,
-                        scope: {
+                        data: {
                             hello: 'overwritten!'
                         }
                     })
@@ -501,7 +500,7 @@ describe('UNIT: API', function () {
                         attributes: {
                             'v-test': 'ok'
                         },
-                        scope: {
+                        data: {
                             ok: true
                         }
                     })
@@ -524,7 +523,7 @@ describe('UNIT: API', function () {
                     })
                     var t = new Test({
                         template: '{{hi | test}}',
-                        scope: {
+                        data: {
                             hi: 'hohoho'
                         }
                     })
@@ -537,13 +536,13 @@ describe('UNIT: API', function () {
 
                 it('should allow the VM to use private child VMs', function () {
                     var Child = Vue.extend({
-                        scope: {
+                        data: {
                             name: 'child'
                         }
                     })
                     var Parent = Vue.extend({
                         template: '<p>{{name}}</p><div v-component="child">{{name}}</div>',
-                        scope: {
+                        data: {
                             name: 'dad'
                         },
                         components: {
@@ -558,12 +557,12 @@ describe('UNIT: API', function () {
                 it('should work with plain option object', function () {
                     var Parent = Vue.extend({
                         template: '<p>{{name}}</p><div v-component="child">{{name}}</div>',
-                        scope: {
+                        data: {
                             name: 'dad'
                         },
                         components: {
                             child: {
-                                scope: {
+                                data: {
                                     name: 'child'
                                 }
                             }
@@ -586,7 +585,7 @@ describe('UNIT: API', function () {
                         partials: {
                             test: '<a>{{a}}</a><p>{{b}}</p>'
                         },
-                        scope: {
+                        data: {
                             a: 'hi',
                             b: 'ho'
                         }
@@ -622,7 +621,7 @@ describe('UNIT: API', function () {
                                 }
                             }
                         },
-                        scope: {
+                        data: {
                             show: false
                         }
                     })

+ 4 - 4
test/unit/specs/directives.js

@@ -557,7 +557,7 @@ describe('UNIT: Directives', function () {
             mock(testId, '<span v-pre><strong>{{lol}}</strong><a v-text="hi"></a></span>')
             var t = new Vue({
                 el: '#' + testId,
-                scope: {
+                data: {
                     lol: 'heyhey',
                     hi: 'hohoho'
                 }
@@ -576,7 +576,7 @@ describe('UNIT: Directives', function () {
             mock(testId, '<div v-component="' + testId + '"></div>')
             var t = new Vue({
                 el: '#' + testId,
-                scope: {
+                data: {
                     msg: '123'
                 },
                 components: {
@@ -593,7 +593,7 @@ describe('UNIT: Directives', function () {
             mock(testId, '<div v-component="' + testId + ':options.test"></div>')
             var t = new Vue({
                 el: '#' + testId,
-                scope: {
+                data: {
                     options: {
                         test: {
                             msg: '123'
@@ -616,7 +616,7 @@ describe('UNIT: Directives', function () {
         it('should register a VM isntance on its parent\'s $', function () {
             var called = false
             var Child = Vue.extend({
-                proto: {
+                methods: {
                     test: function () {
                         called = true
                     }

+ 3 - 3
test/unit/specs/exp-parser.js

@@ -54,7 +54,7 @@ describe('UNIT: Expression Parser', function () {
             expectedValue: 'write tests : nope'
         },
         {
-            // expression with no scope variables
+            // expression with no data variables
             exp: "'a' + 'b'",
             vm: {},
             expectedValue: 'ab'
@@ -69,7 +69,7 @@ describe('UNIT: Expression Parser', function () {
             var caughtMissingPaths = [],
                 compilerMock = {
                     vm:{
-                        $scope: {},
+                        $data: {},
                         $compiler:{
                             bindings:{},
                             createBinding: function (path) {
@@ -114,7 +114,7 @@ describe('UNIT: Expression Parser', function () {
                         bindings: {},
                         createBinding: function () {}
                     },
-                    $scope: {}
+                    $data: {}
                 }
             })
             assert.ok(warned)

+ 5 - 5
test/unit/specs/observer.js

@@ -471,12 +471,12 @@ describe('UNIT: Observer', function () {
                 if (expect.skip) return
                 var path = expect.key.split('.'),
                     j = 1,
-                    scope = obj
+                    data = obj
                 while (j < path.length - 1) {
-                    scope = scope[path[j]]
+                    data = data[path[j]]
                     j++
                 }
-                scope[path[j]] = expect.val
+                data[path[j]] = expect.val
             })
             assert.strictEqual(i, expects.length)
         }
@@ -497,9 +497,9 @@ describe('UNIT: Observer', function () {
             expects.forEach(function (key) {
                 var path = key.split('.'),
                     j = 1,
-                    scope = obj
+                    data = obj
                 while (j < path.length) {
-                    scope = scope[path[j]]
+                    data = data[path[j]]
                     j++
                 }
             })

+ 4 - 4
test/unit/specs/utils.js

@@ -206,8 +206,8 @@ describe('UNIT: Utils', function () {
                 b: '<div class="a">hi</div><p>ha</p>'
             },
             components: {
-                a: { scope: { data: 1 } },
-                b: { scope: { data: 2 } }
+                a: { data: { data: 1 } },
+                b: { data: { data: 2 } }
             },
             template: '<a>{{hi}}</a>'
         }
@@ -234,9 +234,9 @@ describe('UNIT: Utils', function () {
         it('should convert plain object components & elements to constructors', function () {
             var components = options.components
             assert.ok(components.a.prototype instanceof Vue)
-            assert.strictEqual(components.a.options.scope.data, 1)
+            assert.strictEqual(components.a.options.data.data, 1)
             assert.ok(components.b.prototype instanceof Vue)
-            assert.strictEqual(components.b.options.scope.data, 2)
+            assert.strictEqual(components.b.options.data.data, 2)
         })
 
     })

+ 1 - 1
test/unit/specs/viewmodel.js

@@ -9,7 +9,7 @@ describe('UNIT: ViewModel', function () {
         arr = [1, 2, 3],
         vm = new Vue({
             el: '#vm-test',
-            scope: {
+            data: {
                 a: data,
                 b: arr
             }

+ 3 - 3
test/unit/vendor/mocha.js

@@ -5093,13 +5093,13 @@ exports.escape = function(html){
  *
  * @param {Array} array
  * @param {Function} fn
- * @param {Object} scope
+ * @param {Object} data
  * @api private
  */
 
-exports.forEach = function(arr, fn, scope){
+exports.forEach = function(arr, fn, data){
   for (var i = 0, l = arr.length; i < l; i++)
-    fn.call(scope, arr[i], i);
+    fn.call(data, arr[i], i);
 };
 
 /**