diff --git a/src/main.js b/src/main.js index 62a0030ff..1faaeefff 100644 --- a/src/main.js +++ b/src/main.js @@ -75,11 +75,13 @@ function extend (options) { var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype) utils.defProtected(proto, 'constructor', ExtendedVM) // copy prototype props - if (options.props) { - utils.extend(proto, options.props, function (key) { - // do not overwrite the ancestor ViewModel prototype methods - return !(key in ViewModel.prototype) - }) + var props = options.props + if (props) { + for (var key in props) { + if (!(key in ViewModel.prototype)) { + proto[key] = props[key] + } + } } // convert template to documentFragment if (options.template) { diff --git a/src/utils.js b/src/utils.js index 0604aee98..3ca14e573 100644 --- a/src/utils.js +++ b/src/utils.js @@ -3,6 +3,8 @@ var config = require('./config'), module.exports = { + // global storage for user-registered + // vms, partials and transitions vms : {}, partials : {}, transitions : {}, @@ -21,22 +23,33 @@ module.exports = { }) }, + /* + * Accurate type check + */ typeOf: function (obj) { return toString.call(obj).slice(8, -1) }, - extend: function (obj, ext, qualifier) { + /* + * simple extend + */ + extend: function (obj, ext) { for (var key in ext) { - if (qualifier && !qualifier(key)) continue obj[key] = ext[key] } }, + /* + * log for debugging + */ log: function () { if (config.debug) console.log.apply(console, arguments) return this }, + /* + * warn for debugging + */ warn: function() { if (config.debug) console.warn.apply(console, arguments) return this