Browse Source

vm.$options

Evan You 12 years ago
parent
commit
c6961aeb46
2 changed files with 7 additions and 6 deletions
  1. 2 1
      src/compiler.js
  2. 5 5
      test/unit/specs/api.js

+ 2 - 1
src/compiler.js

@@ -66,6 +66,7 @@ function Compiler (vm, options) {
     // set inenumerable VM properties
     def(vm, '$', makeHash())
     def(vm, '$el', el)
+    def(vm, '$options', options)
     def(vm, '$compiler', compiler)
 
     // set parent VM
@@ -252,7 +253,7 @@ CompilerProto.setupObserver = function () {
 
     function registerHook (hook, fn) {
         observer.on('hook:' + hook, function () {
-            fn.call(compiler.vm, options)
+            fn.call(compiler.vm)
         })
     }
 

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

@@ -851,8 +851,8 @@ describe('UNIT: API', function () {
                     it('should be called before compile', function () {
                         
                         var called = false,
-                            Test = Vue.extend({ created: function (options) {
-                                assert.ok(options.ok)
+                            Test = Vue.extend({ created: function () {
+                                assert.ok(this.$options.ok)
                                 called = true
                             }})
                         new Test({ ok: true })
@@ -864,10 +864,10 @@ describe('UNIT: API', function () {
 
                 describe('ready', function () {
 
-                    it('should be called after compile with options', function () {
+                    it('should be called after compile', function () {
                         var called = false,
-                            hook = function (options) {
-                                assert.ok(options.ok)
+                            hook = function () {
+                                assert.ok(this.$options.ok)
                                 assert.notOk(this.$compiler.init)
                                 called = true
                             },