Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update viewmodel.js #344

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/viewmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ var Compiler = require('./compiler'),
* and a few reserved methods
*/
function ViewModel (options) {
// just compile. options are passed directly to compiler
// compile if options passed, if false return. options are passed directly to compiler
if (options === false) return;
new Compiler(this, options)
}

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

/**
* init allows config compilation after instantiation
* var a = new Vue(false); a.init( config );
*/
def(VMProto, '$init', function (options) {
new Compiler( this, options )
})

/**
* Convenience function to get a value from
* a keypath
Expand Down Expand Up @@ -177,4 +186,4 @@ function query (el) {
: el
}

module.exports = ViewModel
module.exports = ViewModel