mirror of https://github.com/vuejs/vue.git
clean up utils
This commit is contained in:
parent
6fcce9752a
commit
61bddb07d5
12
src/main.js
12
src/main.js
|
|
@ -75,11 +75,13 @@ function extend (options) {
|
||||||
var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype)
|
var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype)
|
||||||
utils.defProtected(proto, 'constructor', ExtendedVM)
|
utils.defProtected(proto, 'constructor', ExtendedVM)
|
||||||
// copy prototype props
|
// copy prototype props
|
||||||
if (options.props) {
|
var props = options.props
|
||||||
utils.extend(proto, options.props, function (key) {
|
if (props) {
|
||||||
// do not overwrite the ancestor ViewModel prototype methods
|
for (var key in props) {
|
||||||
return !(key in ViewModel.prototype)
|
if (!(key in ViewModel.prototype)) {
|
||||||
})
|
proto[key] = props[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// convert template to documentFragment
|
// convert template to documentFragment
|
||||||
if (options.template) {
|
if (options.template) {
|
||||||
|
|
|
||||||
17
src/utils.js
17
src/utils.js
|
|
@ -3,6 +3,8 @@ var config = require('./config'),
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
// global storage for user-registered
|
||||||
|
// vms, partials and transitions
|
||||||
vms : {},
|
vms : {},
|
||||||
partials : {},
|
partials : {},
|
||||||
transitions : {},
|
transitions : {},
|
||||||
|
|
@ -21,22 +23,33 @@ module.exports = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accurate type check
|
||||||
|
*/
|
||||||
typeOf: function (obj) {
|
typeOf: function (obj) {
|
||||||
return toString.call(obj).slice(8, -1)
|
return toString.call(obj).slice(8, -1)
|
||||||
},
|
},
|
||||||
|
|
||||||
extend: function (obj, ext, qualifier) {
|
/*
|
||||||
|
* simple extend
|
||||||
|
*/
|
||||||
|
extend: function (obj, ext) {
|
||||||
for (var key in ext) {
|
for (var key in ext) {
|
||||||
if (qualifier && !qualifier(key)) continue
|
|
||||||
obj[key] = ext[key]
|
obj[key] = ext[key]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* log for debugging
|
||||||
|
*/
|
||||||
log: function () {
|
log: function () {
|
||||||
if (config.debug) console.log.apply(console, arguments)
|
if (config.debug) console.log.apply(console, arguments)
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* warn for debugging
|
||||||
|
*/
|
||||||
warn: function() {
|
warn: function() {
|
||||||
if (config.debug) console.warn.apply(console, arguments)
|
if (config.debug) console.warn.apply(console, arguments)
|
||||||
return this
|
return this
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue