vue-server
Advanced tools
Comparing version 0.4.0-beta.5 to 0.4.0-beta.6
{ | ||
"name": "vue-server", | ||
"version": "0.4.0-beta.5", | ||
"version": "0.4.0-beta.6", | ||
"description": "Vue.js server side version", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -202,3 +202,3 @@ var _ = require('underscore'); | ||
getRepeatData: function (vm, dir) { | ||
var value = vm.$get(dir.expression); | ||
var value = common.getValue(vm, dir.get); | ||
var array; | ||
@@ -370,3 +370,3 @@ | ||
if (!component.__composed) { | ||
component.__composed = common.composeComponent(component); | ||
component.__composed = common.composeComponent(component, vm.$root.__states.mixin); | ||
} | ||
@@ -373,0 +373,0 @@ |
@@ -222,3 +222,3 @@ var Path = require('./../parsers/path'); | ||
composeComponent: function (component) { | ||
composeComponent: function (component, globalMixin) { | ||
var options = {}; | ||
@@ -249,2 +249,8 @@ var rawVm = {}; | ||
// Global mixin via Vue.mixin = ... | ||
if (globalMixin) { | ||
options.mixins = options.mixins || []; | ||
options.mixins = globalMixin.concat(options.mixins); | ||
} | ||
options.template = common.prepareTemplate(options.template, 'Component\'s template'); | ||
@@ -251,0 +257,0 @@ |
@@ -14,3 +14,3 @@ var _ = require('underscore'); | ||
var makeRootVm = function (instance) { | ||
var VueRoot = function (instance) { | ||
var that = this; | ||
@@ -34,2 +34,3 @@ var vm; | ||
scope.components = this._components; | ||
scope.mixin = this.mixin || null; | ||
@@ -44,3 +45,3 @@ renders.$logger = that.logger; | ||
components: {}, | ||
component: common.composeComponent(instance), | ||
component: common.composeComponent(instance, this.mixin), | ||
isComponent: true | ||
@@ -80,118 +81,125 @@ }); | ||
makeRootVm.component = this.component; | ||
makeRootVm.filter = this.filter; | ||
makeRootVm.partial = this.partial; | ||
makeRootVm.prototype._components = {}; | ||
makeRootVm.prototype._filters = filtersGlobal; | ||
makeRootVm.prototype._partials = {}; | ||
makeRootVm.prototype._logger = logger; | ||
makeRootVm.prototype._initLogger = this._initLogger; | ||
makeRootVm.prototype._checkVmsReady = this._checkVmsReady; | ||
makeRootVm.prototype.config = { | ||
debug: false, | ||
silent: false, | ||
strict: false, | ||
replace: true, | ||
onLogMessage: null | ||
}; | ||
makeRootVm.config = makeRootVm.prototype.config; | ||
return makeRootVm; | ||
}; | ||
// Check for VM ready | ||
VueRender.prototype._checkVmsReady = function (vm) { | ||
if (!vm._isReady) { | ||
return false; | ||
} | ||
if (vm.__states.children) { | ||
for (var item in vm.__states.children) { | ||
if (!this._checkVmsReady(vm.__states.children[item])) { | ||
return false; | ||
} | ||
VueRoot.prototype.component = function (id, component) { | ||
if (!component) { | ||
this.logger.debug('global component\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
} | ||
return true; | ||
}; | ||
this.prototype._components[id] = component; | ||
// Declaring global components | ||
VueRender.prototype.component = function (id, component) { | ||
if (!component) { | ||
this.logger.debug('global component\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
}; | ||
this.prototype._components[id] = component; | ||
VueRoot.prototype.filter = function (id, filter) { | ||
if (!filter) { | ||
this.logger.debug('global filter\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
return this; | ||
}; | ||
this.prototype._filters[id] = filter; | ||
VueRender.prototype.filter = function (id, filter) { | ||
if (!filter) { | ||
this.logger.debug('global filter\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
}; | ||
this.prototype._filters[id] = filter; | ||
VueRoot.prototype.partial = function (id, partial) { | ||
if (!partial) { | ||
this.logger.debug('global partial\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
return this; | ||
}; | ||
this.prototype._partials[id] = partial; | ||
VueRender.prototype.partial = function (id, partial) { | ||
if (!partial) { | ||
this.logger.debug('global partial\'s content is empty: "' + id + '"'); | ||
return this; | ||
} | ||
}; | ||
this.prototype._partials[id] = partial; | ||
return this; | ||
}; | ||
// Check for VM ready | ||
VueRoot.prototype._checkVmsReady = function (vm) { | ||
if (!vm._isReady) { | ||
return false; | ||
} | ||
VueRender.prototype._initLogger = function (config, logger) { | ||
return { | ||
_config: config, | ||
_logger: logger, | ||
log: function () { | ||
if (!this._config.silent) { | ||
this._logger.debug.apply(this._logger, arguments); | ||
if (vm.__states.children) { | ||
for (var item in vm.__states.children) { | ||
if (!this._checkVmsReady(vm.__states.children[item])) { | ||
return false; | ||
} | ||
} | ||
} | ||
return this; | ||
}, | ||
debug: function () { | ||
if (!this._config.silent && this._config.debug) { | ||
this._logger.debug.apply(this._logger, arguments); | ||
} | ||
return true; | ||
}; | ||
return this; | ||
}, | ||
info: function () { | ||
if (!this._config.silent && this._config.debug) { | ||
this._logger.info.apply(this._logger, arguments); | ||
} | ||
VueRoot.prototype._initLogger = function (config, logger) { | ||
return { | ||
_config: config, | ||
_logger: logger, | ||
log: function () { | ||
if (!this._config.silent) { | ||
this._logger.debug.apply(this._logger, arguments); | ||
} | ||
return this; | ||
}, | ||
warn: function () { | ||
if (!this._config.silent) { | ||
this._logger.warn.apply(this._logger, arguments); | ||
return this; | ||
}, | ||
debug: function () { | ||
if (!this._config.silent && this._config.debug) { | ||
this._logger.debug.apply(this._logger, arguments); | ||
} | ||
return this; | ||
}, | ||
info: function () { | ||
if (!this._config.silent && this._config.debug) { | ||
this._logger.info.apply(this._logger, arguments); | ||
} | ||
return this; | ||
}, | ||
warn: function () { | ||
if (!this._config.silent) { | ||
this._logger.warn.apply(this._logger, arguments); | ||
} | ||
return this; | ||
}, | ||
error: function () { | ||
if (!this._config.silent) { | ||
this._logger.error.apply(this._logger, arguments); | ||
} | ||
return this; | ||
} | ||
}; | ||
}; | ||
return this; | ||
Object.defineProperty(VueRoot, 'mixin', { | ||
get: function () { | ||
return this.prototype.mixin; | ||
}, | ||
error: function () { | ||
if (!this._config.silent) { | ||
this._logger.error.apply(this._logger, arguments); | ||
} | ||
set: function (val) { | ||
this.prototype.mixin = val; | ||
} | ||
}); | ||
return this; | ||
} | ||
VueRoot.prototype._logger = logger; | ||
VueRoot.prototype._components = {}; | ||
VueRoot.prototype._filters = filtersGlobal; | ||
VueRoot.prototype._partials = {}; | ||
VueRoot.prototype.config = { | ||
debug: false, | ||
silent: false, | ||
strict: false, | ||
replace: true, | ||
onLogMessage: null | ||
}; | ||
VueRoot.config = VueRoot.prototype.config; | ||
return VueRoot; | ||
}; | ||
module.exports = VueRender; |
@@ -99,3 +99,3 @@ var common = require('./common.js'); | ||
}; | ||
vm.__states.TIMER = 0; | ||
vm.__states.mixin = this.mixin; | ||
} | ||
@@ -604,9 +604,16 @@ | ||
if (descriptor.type) { | ||
if (!value || value.constructor != descriptor.type) { | ||
var type; | ||
if (value === null || value === undefined) { | ||
type = value; | ||
} else { | ||
type = value.constructor.name; | ||
} | ||
var hasTypeError = false; | ||
var type; | ||
if (value === null || value === undefined) { | ||
hasTypeError = true; | ||
type = value; | ||
} | ||
if (value.constructor != descriptor.type) { | ||
hasTypeError = true; | ||
type = value.constructor.name; | ||
} | ||
if (hasTypeError) { | ||
vm.$logger.warn( | ||
@@ -613,0 +620,0 @@ 'Invalid prop: type check failed for "' + propName + '". Expected ' + |
@@ -7,3 +7,4 @@ var wrapComponent = require('./wrapComponent.js'); | ||
return { | ||
transmit: 'value present' | ||
transmit: 'value present', | ||
bool: false | ||
}; | ||
@@ -17,2 +18,3 @@ }, | ||
'<type value="{{transmit}}"></type>', | ||
'<type-boolean value="{{bool}}"></type-boolean>', | ||
'<type-default value="{{transmit}}"></type-default>', | ||
@@ -48,3 +50,10 @@ '<default-straight></default-straight>', | ||
}, | ||
'type-boolean': { | ||
props: { | ||
value: { | ||
type: Boolean | ||
} | ||
}, | ||
template: '<div>{{value === false}}</div>' | ||
}, | ||
'type-default': { | ||
@@ -138,2 +147,6 @@ props: { | ||
it('to use type Boolean option correctly', function () { | ||
expect($('type-boolean > div').text()).toEqual('true'); | ||
}); | ||
it('to use type option with default option correctly', function () { | ||
@@ -140,0 +153,0 @@ expect($('type-default > div').text()).toEqual(''); |
349059
9750