Skip to content

Commit b784efe

Browse files
author
Ted Patrick
committed
Update viewmodel.js
Allow passing false to constructor to bypass compilation. Add vue.init( config) to defer setting configuration after construction has completed.
1 parent 4bc1243 commit b784efe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/viewmodel.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@ var Compiler = require('./compiler'),
1616
* and a few reserved methods
1717
*/
1818
function ViewModel (options) {
19-
// just compile. options are passed directly to compiler
19+
// compile if options passed, if false return. options are passed directly to compiler
20+
if( options === false ) return;
2021
new Compiler(this, options)
2122
}
2223

2324
// All VM prototype methods are inenumerable
2425
// so it can be stringified/looped through as raw data
2526
var VMProto = ViewModel.prototype
2627

28+
/**
29+
* init allows config compilation after instantiation
30+
* var a = new Vue(false); a.init( config );
31+
*/
32+
def(VMProto, 'init', function (options) {
33+
new Compiler( this, options )
34+
})
35+
2736
/**
2837
* Convenience function to get a value from
2938
* a keypath
@@ -177,4 +186,4 @@ function query (el) {
177186
: el
178187
}
179188

180-
module.exports = ViewModel
189+
module.exports = ViewModel

0 commit comments

Comments
 (0)