Comparing version 0.12.1 to 0.12.2
{ | ||
"name": "vue", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"author": "Evan You <yyx990803@gmail.com>", | ||
@@ -25,6 +25,7 @@ "license": "MIT", | ||
"casperjs": "^1.1.0-beta3", | ||
"codecov.io": "^0.1.2", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-karma": "^0.8.3", | ||
"grunt-karma-coveralls": "^2.5.3", | ||
"jasmine-core": "^2.3.4", | ||
"jshint-stylish": "^0.3.0", | ||
@@ -36,3 +37,3 @@ "karma": "^0.12.31", | ||
"karma-firefox-launcher": "^0.1.4", | ||
"karma-jasmine": "^0.2.3", | ||
"karma-jasmine": "^0.3.5", | ||
"karma-phantomjs-launcher": "^0.1.4", | ||
@@ -39,0 +40,0 @@ "karma-safari-launcher": "^0.1.1", |
<p align="center"><a href="http://vuejs.org" target="_blank"><img width="100"src="http://vuejs.org/images/logo.png"></a></p> | ||
# Vue.js [![Build Status](https://travis-ci.org/yyx990803/vue.svg?branch=master)](https://travis-ci.org/yyx990803/vue) [![Selenium Test Status](https://saucelabs.com/buildstatus/vuejs)](https://saucelabs.com/u/vuejs) [![Coverage Status](https://img.shields.io/coveralls/yyx990803/vue.svg)](https://coveralls.io/r/yyx990803/vue?branch=master) | ||
# Vue.js [![Build Status](https://img.shields.io/circleci/project/yyx990803/vue/master.svg)](https://circleci.com/gh/yyx990803/vue) [![Coverage Status](https://img.shields.io/codecov/c/github/yyx990803/vue/master.svg)](https://codecov.io/github/yyx990803/vue?branch=master) [![Selenium Test Status](https://saucelabs.com/buildstatus/vuejs)](https://saucelabs.com/u/vuejs) | ||
@@ -39,2 +39,2 @@ ## Intro | ||
Copyright (c) 2014 Evan You | ||
Copyright (c) 2014 Evan You |
var _ = require('./util') | ||
var MAX_UPDATE_COUNT = 10 | ||
var config = require('./config') | ||
@@ -73,3 +73,3 @@ // we have two separate queues: one for directive updates | ||
// detect possible infinite update loops | ||
if (has[id] > MAX_UPDATE_COUNT) { | ||
if (has[id] > config._maxUpdateCount) { | ||
_.warn( | ||
@@ -96,2 +96,2 @@ 'You may have an infinite update loop for the ' + | ||
} | ||
} | ||
} |
@@ -68,13 +68,4 @@ var _ = require('../util') | ||
}, vm) | ||
/** | ||
* The linker function returns an unlink function that | ||
* tearsdown all directives instances generated during | ||
* the process. | ||
* | ||
* @param {Boolean} destroying | ||
*/ | ||
return function unlink (destroying) { | ||
teardownDirs(vm, dirs, destroying) | ||
} | ||
// | ||
return makeUnlinkFn(vm, dirs) | ||
} | ||
@@ -98,2 +89,26 @@ } | ||
/** | ||
* Linker functions return an unlink function that | ||
* tearsdown all directives instances generated during | ||
* the process. | ||
* | ||
* We create unlink functions with only the necessary | ||
* information to avoid retaining additional closures. | ||
* | ||
* @param {Vue} vm | ||
* @param {Array} dirs | ||
* @param {Vue} [parent] | ||
* @param {Array} [parentDirs] | ||
* @return {Function} | ||
*/ | ||
function makeUnlinkFn (vm, dirs, parent, parentDirs) { | ||
return function unlink (destroying) { | ||
teardownDirs(vm, dirs, destroying) | ||
if (parent && parentDirs) { | ||
teardownDirs(parent, parentDirs) | ||
} | ||
} | ||
} | ||
/** | ||
* Teardown partial linked directives. | ||
@@ -107,3 +122,2 @@ * | ||
function teardownDirs (vm, dirs, destroying) { | ||
if (!dirs) return | ||
var i = dirs.length | ||
@@ -119,12 +133,26 @@ while (i--) { | ||
/** | ||
* Compile the root element of an instance. There are | ||
* 3 types of things to process here: | ||
* Compile link props on an instance. | ||
* | ||
* 1. props on parent container (child scope) | ||
* 2. other attrs on parent container (parent scope) | ||
* 3. attrs on the component template root node, if | ||
* @param {Vue} vm | ||
* @param {Element} el | ||
* @param {Object} options | ||
* @return {Function} | ||
*/ | ||
exports.compileAndLinkProps = function (vm, el, props) { | ||
var propsLinkFn = compileProps(el, props) | ||
var propDirs = linkAndCapture(function () { | ||
propsLinkFn(vm, null) | ||
}, vm) | ||
return makeUnlinkFn(vm, propDirs) | ||
} | ||
/** | ||
* Compile the root element of an instance. | ||
* | ||
* 1. attrs on parent container (parent scope) | ||
* 2. attrs on the component template root node, if | ||
* replace:true (child scope) | ||
* | ||
* Also, if this is a block instance, we only need to | ||
* compile 1 & 2 here. | ||
* If this is a block instance, we only need to compile 1. | ||
* | ||
@@ -145,10 +173,4 @@ * This function does compile and link at the same time, | ||
var replacerAttrs = options._replacerAttrs | ||
var props = options.props | ||
var propsLinkFn, parentLinkFn, replacerLinkFn | ||
var parentLinkFn, replacerLinkFn | ||
// 1. props | ||
propsLinkFn = props | ||
? compileProps(el, containerAttrs || {}, props) | ||
: null | ||
// only need to compile other attributes for | ||
@@ -185,3 +207,2 @@ // non-block instances | ||
var selfDirs = linkAndCapture(function () { | ||
if (propsLinkFn) propsLinkFn(vm, null) | ||
if (replacerLinkFn) replacerLinkFn(vm, el) | ||
@@ -192,6 +213,3 @@ }, vm) | ||
// container directives. | ||
return function rootUnlinkFn () { | ||
teardownDirs(parent, parentDirs) | ||
teardownDirs(vm, selfDirs) | ||
} | ||
return makeUnlinkFn(vm, selfDirs, parent, parentDirs) | ||
} | ||
@@ -237,3 +255,3 @@ | ||
if (!linkFn) { | ||
linkFn = checkComponent(el, options) | ||
linkFn = checkComponent(el, options, hasAttrs) | ||
} | ||
@@ -406,3 +424,2 @@ // normal directives | ||
* @param {Element|DocumentFragment} el | ||
* @param {Object} attrs | ||
* @param {Array} propDescriptors | ||
@@ -414,6 +431,6 @@ * @return {Function} propsLinkFn | ||
var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/ | ||
var literalValueRE = /^(true|false)$|\d.*/ | ||
var literalValueRE = /^(true|false)$|^\d.*/ | ||
var identRE = require('../parsers/path').identRE | ||
function compileProps (el, attrs, propDescriptors) { | ||
function compileProps (el, propDescriptors) { | ||
var props = [] | ||
@@ -451,12 +468,15 @@ var i = propDescriptors.length | ||
} | ||
value = attrs[name] | ||
/* jshint eqeqeq:false */ | ||
if (value != null) { | ||
prop = { | ||
name: name, | ||
raw: value, | ||
path: path, | ||
assertions: assertions, | ||
mode: propBindingModes.ONE_WAY | ||
} | ||
value = el.getAttribute(name) | ||
// create a prop descriptor | ||
prop = { | ||
name: name, | ||
raw: value, | ||
path: path, | ||
assertions: assertions, | ||
mode: propBindingModes.ONE_WAY | ||
} | ||
if (value !== null) { | ||
// important so that this doesn't get compiled | ||
// again as a normal attribute binding | ||
el.removeAttribute(name) | ||
var tokens = textParser.parse(value) | ||
@@ -467,5 +487,2 @@ if (tokens) { | ||
} | ||
// important so that this doesn't get compiled | ||
// again as a normal attribute binding | ||
attrs[name] = null | ||
prop.dynamic = true | ||
@@ -493,8 +510,6 @@ prop.parentPath = textParser.tokensToExp(tokens) | ||
} | ||
props.push(prop) | ||
} else if (assertions && assertions.required) { | ||
_.warn( | ||
'Missing required prop: ' + name | ||
) | ||
_.warn('Missing required prop: ' + name) | ||
} | ||
props.push(prop) | ||
} | ||
@@ -518,3 +533,7 @@ return makePropsLinkFn(props) | ||
path = prop.path | ||
if (prop.dynamic) { | ||
if (prop.raw === null) { | ||
// initialize undefined prop | ||
vm._data[path] = undefined | ||
} else if (prop.dynamic) { | ||
// dynamic prop | ||
if (vm.$parent) { | ||
@@ -525,3 +544,3 @@ if (prop.mode === propBindingModes.ONE_TIME) { | ||
if (_.assertProp(prop, value)) { | ||
vm.$set(path, value) | ||
vm[path] = vm._data[path] = value | ||
} | ||
@@ -543,3 +562,3 @@ } else { | ||
if (_.assertProp(prop, value)) { | ||
vm.$set(path, value) | ||
vm[path] = vm._data[path] = value | ||
} | ||
@@ -573,7 +592,8 @@ } | ||
* @param {Object} options | ||
* @param {Boolean} hasAttrs | ||
* @return {Function|undefined} | ||
*/ | ||
function checkComponent (el, options) { | ||
var componentId = _.checkComponent(el, options) | ||
function checkComponent (el, options, hasAttrs) { | ||
var componentId = _.checkComponent(el, options, hasAttrs) | ||
if (componentId) { | ||
@@ -663,3 +683,2 @@ var componentLinkFn = function (vm, el, host) { | ||
value = attr.value | ||
if (value === null) continue | ||
if (name.indexOf(config.prefix) === 0) { | ||
@@ -666,0 +685,0 @@ dirName = name.slice(config.prefix.length) |
@@ -66,9 +66,14 @@ var _ = require('../util') | ||
var replacer = frag.firstChild | ||
var tag = replacer.tagName && replacer.tagName.toLowerCase() | ||
if (options.replace) { | ||
if ( | ||
// multi-children template | ||
frag.childNodes.length > 1 || | ||
// non-element template | ||
replacer.nodeType !== 1 || | ||
// when root node has v-repeat, the instance ends up | ||
// having multiple top-level nodes, thus becoming a | ||
// block instance. (#835) | ||
// when root node is <content>, <partial> or has | ||
// v-repeat, the instance could end up having | ||
// multiple top-level nodes, thus becoming a block | ||
// instance. | ||
tag === 'content' || tag === 'partial' || | ||
replacer.hasAttribute(config.prefix + 'repeat') | ||
@@ -75,0 +80,0 @@ ) { |
@@ -88,4 +88,10 @@ module.exports = { | ||
ONE_TIME: 2 | ||
} | ||
}, | ||
/** | ||
* Max circular updates allowed in a batcher flush cycle. | ||
*/ | ||
_maxUpdateCount: 100 | ||
} | ||
@@ -92,0 +98,0 @@ |
@@ -29,2 +29,4 @@ var _ = require('../util') | ||
this.keepAlive = this._checkParam('keep-alive') != null | ||
// wait for event before insertion | ||
this.readyEvent = this._checkParam('wait-for') | ||
// check ref | ||
@@ -46,10 +48,5 @@ this.refID = _.attr(this.el, 'ref') | ||
if (!this._isDynamicLiteral) { | ||
this.resolveCtor(this.expression, _.bind(function () { | ||
var child = this.build() | ||
child.$before(this.anchor) | ||
this.setCurrent(child) | ||
}, this)) | ||
this.resolveCtor(this.expression, _.bind(this.initStatic, this)) | ||
} else { | ||
// check dynamic component params | ||
this.readyEvent = this._checkParam('wait-for') | ||
this.transMode = this._checkParam('transition-mode') | ||
@@ -59,4 +56,6 @@ } | ||
_.warn( | ||
'v-component="' + this.expression + '" cannot be ' + | ||
'used on an already mounted instance.' | ||
'Do not create a component that only contains ' + | ||
'a single other component - they will be mounted to ' + | ||
'the same element and cause conflict. Wrap it with ' + | ||
'an outer element.' | ||
) | ||
@@ -67,2 +66,19 @@ } | ||
/** | ||
* Initialize a static component. | ||
*/ | ||
initStatic: function () { | ||
var child = this.build() | ||
var anchor = this.anchor | ||
this.setCurrent(child) | ||
if (!this.readyEvent) { | ||
child.$before(anchor) | ||
} else { | ||
child.$once(this.readyEvent, function () { | ||
child.$before(anchor) | ||
}) | ||
} | ||
}, | ||
/** | ||
* Public update, called by the watcher in the dynamic | ||
@@ -285,3 +301,2 @@ * literal scenario, e.g. v-component="{{view}}" | ||
} | ||
} |
@@ -31,3 +31,3 @@ var _ = require('../util') | ||
'v-if="' + this.expression + '" cannot be ' + | ||
'used on an already mounted instance.' | ||
'used on an instance root element.' | ||
) | ||
@@ -43,3 +43,6 @@ } | ||
if (!this.unlink) { | ||
this.compile() | ||
this.link( | ||
templateParser.clone(this.template), | ||
this.linker | ||
) | ||
} | ||
@@ -51,8 +54,5 @@ } else { | ||
compile: function () { | ||
link: function (frag, linker) { | ||
var vm = this.vm | ||
var frag = templateParser.clone(this.template) | ||
// the linker is not guaranteed to be present because | ||
// this function might get called by v-partial | ||
this.unlink = this.linker(vm, frag) | ||
this.unlink = linker(vm, frag) | ||
transition.blockAppend(frag, this.end, vm) | ||
@@ -130,2 +130,2 @@ // call attached for all the child components created | ||
} | ||
} | ||
} |
@@ -0,1 +1,6 @@ | ||
// NOTE: the prop internal directive is compiled and linked | ||
// during _initScope(), before the created hook is called. | ||
// The purpose is to make the initial prop values available | ||
// inside `created` hooks and `data` functions. | ||
var _ = require('../util') | ||
@@ -20,2 +25,13 @@ var Watcher = require('../watcher') | ||
var locked = false | ||
function withLock (fn) { | ||
return function (val) { | ||
if (!locked) { | ||
locked = true | ||
fn(val) | ||
_.nextTick(function () { | ||
locked = false | ||
}) | ||
} | ||
} | ||
} | ||
@@ -25,21 +41,19 @@ this.parentWatcher = new Watcher( | ||
parentKey, | ||
function (val) { | ||
if (!locked) { | ||
locked = true | ||
// all props have been initialized already | ||
if (_.assertProp(prop, val)) { | ||
child[childKey] = val | ||
} | ||
locked = false | ||
withLock(function (val) { | ||
if (_.assertProp(prop, val)) { | ||
child[childKey] = val | ||
} | ||
}, | ||
{ sync: true } | ||
}) | ||
) | ||
// set the child initial value first, before setting | ||
// up the child watcher to avoid triggering it | ||
// immediately. | ||
// set the child initial value. | ||
// !!! We need to set it also on raw data here, because | ||
// props are initialized before data is fully observed | ||
var value = this.parentWatcher.value | ||
if (_.assertProp(prop, value)) { | ||
child.$set(childKey, value) | ||
if (childKey === '$data') { | ||
child._data = value | ||
} else { | ||
child[childKey] = child._data[childKey] = value | ||
} | ||
} | ||
@@ -50,14 +64,14 @@ | ||
if (prop.mode === bindingModes.TWO_WAY) { | ||
this.childWatcher = new Watcher( | ||
child, | ||
childKey, | ||
function (val) { | ||
if (!locked) { | ||
locked = true | ||
parent.$set(parentKey, val) | ||
locked = false | ||
} | ||
}, | ||
{ sync: true } | ||
) | ||
// important: defer the child watcher creation until | ||
// the created hook (after data observation) | ||
var self = this | ||
child.$once('hook:created', function () { | ||
self.childWatcher = new Watcher( | ||
child, | ||
childKey, | ||
withLock(function (val) { | ||
parent[parentKey] = val | ||
}) | ||
) | ||
}) | ||
} | ||
@@ -64,0 +78,0 @@ }, |
@@ -361,3 +361,3 @@ var _ = require('../util') | ||
// linker cachable if no inline-template | ||
_linkerCachable: !this.inlineTemplate, | ||
_linkerCachable: !this.inlineTemplate && Ctor !== _.Vue, | ||
// transclusion host | ||
@@ -506,3 +506,5 @@ _host: this._host, | ||
var index = vm.$index | ||
var key = vm.$key | ||
// fix #948: avoid accidentally fall through to | ||
// a parent repeater which happens to have $key. | ||
var key = vm.hasOwnProperty('$key') && vm.$key | ||
var primitive = !isObject(data) | ||
@@ -509,0 +511,0 @@ if (idKey || key || primitive) { |
@@ -61,16 +61,17 @@ var _ = require('../util') | ||
var digitsRE = /(\d{3})(?=\d)/g | ||
exports.currency = function (value, sign) { | ||
exports.currency = function (value, currency) { | ||
value = parseFloat(value) | ||
if (!isFinite(value) || (!value && value !== 0)) return '' | ||
sign = sign || '$' | ||
var s = Math.floor(Math.abs(value)).toString(), | ||
i = s.length % 3, | ||
h = i > 0 | ||
? (s.slice(0, i) + (s.length > 3 ? ',' : '')) | ||
: '', | ||
v = Math.abs(parseInt((value * 100) % 100, 10)), | ||
f = '.' + (v < 10 ? ('0' + v) : v) | ||
return (value < 0 ? '-' : '') + | ||
sign + h + s.slice(i).replace(digitsRE, '$1,') + f | ||
currency = currency || '$' | ||
var stringified = Math.abs(value).toFixed(2) | ||
var _int = stringified.slice(0, -3) | ||
var i = _int.length % 3 | ||
var head = i > 0 | ||
? (_int.slice(0, i) + (_int.length > 3 ? ',' : '')) | ||
: '' | ||
var _float = stringified.slice(-3) | ||
var sign = value < 0 ? '-' : '' | ||
return currency + sign + head + | ||
_int.slice(i).replace(digitsRE, '$1,') + | ||
_float | ||
} | ||
@@ -77,0 +78,0 @@ |
@@ -142,2 +142,6 @@ var _ = require('../util') | ||
} | ||
// teardown props | ||
if (this._propsUnlinkFn) { | ||
this._propsUnlinkFn() | ||
} | ||
// teardown all directives. this also tearsdown all | ||
@@ -189,2 +193,2 @@ // directive-owned watchers. | ||
this.$off() | ||
} | ||
} |
@@ -76,4 +76,5 @@ var mergeOptions = require('../util').mergeOptions | ||
// set data after merge. | ||
this._data = options.data || {} | ||
// initialize data as empty object. | ||
// it will be filled up in _initScope(). | ||
this._data = {} | ||
@@ -80,0 +81,0 @@ // initialize data observation and scope inheritance. |
@@ -86,2 +86,2 @@ var _ = require('../util') | ||
} | ||
} | ||
} |
var _ = require('../util') | ||
var compiler = require('../compiler') | ||
var Observer = require('../observer') | ||
@@ -15,6 +16,6 @@ var Dep = require('../observer/dep') | ||
this._initProps() | ||
this._initMeta() | ||
this._initMethods() | ||
this._initData() | ||
this._initComputed() | ||
this._initMethods() | ||
this._initMeta() | ||
} | ||
@@ -27,20 +28,15 @@ | ||
exports._initProps = function () { | ||
// make sure all props properties are observed | ||
var data = this._data | ||
var props = this.$options.props | ||
var prop, key, i | ||
if (props) { | ||
i = props.length | ||
while (i--) { | ||
prop = props[i] | ||
// props can be strings or object descriptors | ||
key = _.camelize( | ||
typeof prop === 'string' | ||
? prop | ||
: prop.name | ||
var options = this.$options | ||
var el = options.el | ||
var props = options.props | ||
this._propsUnlinkFn = el && props | ||
? compiler.compileAndLinkProps( | ||
this, el, props | ||
) | ||
if (!(key in data) && key !== '$data') { | ||
data[key] = undefined | ||
} | ||
} | ||
: null | ||
if (props && !el) { | ||
_.warn( | ||
'Props will not be compiled if no `el` option is ' + | ||
'provided at instantiation.' | ||
) | ||
} | ||
@@ -54,4 +50,18 @@ } | ||
exports._initData = function () { | ||
var propsData = this._data | ||
var optionsDataFn = this.$options.data | ||
var optionsData = optionsDataFn && optionsDataFn() | ||
if (optionsData) { | ||
this._data = optionsData | ||
for (var prop in propsData) { | ||
if ( | ||
!optionsData.hasOwnProperty(prop) || | ||
propsData[prop] !== undefined | ||
) { | ||
optionsData[prop] = propsData[prop] | ||
} | ||
} | ||
} | ||
var data = this._data | ||
// proxy data on instance | ||
var data = this._data | ||
var keys = Object.keys(data) | ||
@@ -58,0 +68,0 @@ var i, key |
@@ -85,12 +85,12 @@ var _ = require('../util') | ||
* | ||
* @param {Char} char | ||
* @param {Char} ch | ||
* @return {String} type | ||
*/ | ||
function getPathCharType (char) { | ||
if (char === undefined) { | ||
function getPathCharType (ch) { | ||
if (ch === undefined) { | ||
return 'eof' | ||
} | ||
var code = char.charCodeAt(0) | ||
var code = ch.charCodeAt(0) | ||
@@ -104,3 +104,3 @@ switch(code) { | ||
case 0x30: // 0 | ||
return char | ||
return ch | ||
@@ -107,0 +107,0 @@ case 0x5F: // _ |
@@ -51,9 +51,2 @@ var config = require('../config') | ||
if (type === 'directive') { | ||
if (id === 'component') { | ||
exports.warn( | ||
'v-component can only be used on table elements ' + | ||
'in ^0.12.0. Use custom element syntax instead.' | ||
) | ||
return | ||
} | ||
if (id === 'with') { | ||
@@ -78,2 +71,2 @@ exports.warn( | ||
} | ||
} | ||
} |
@@ -186,2 +186,4 @@ var config = require('../config') | ||
if (el.hasChildNodes()) { | ||
trim(el, el.firstChild) | ||
trim(el, el.lastChild) | ||
rawContent = asFragment | ||
@@ -198,2 +200,8 @@ ? document.createDocumentFragment() | ||
function trim (content, node) { | ||
if (node && node.nodeType === 3 && !node.data.trim()) { | ||
content.removeChild(node) | ||
} | ||
} | ||
/** | ||
@@ -210,2 +218,2 @@ * Check if an element is a template tag. | ||
el.tagName.toLowerCase() === 'template' | ||
} | ||
} |
@@ -175,3 +175,3 @@ /** | ||
exports.isObject = function (obj) { | ||
return obj && typeof obj === 'object' | ||
return obj !== null && typeof obj === 'object' | ||
} | ||
@@ -199,5 +199,3 @@ | ||
exports.isArray = function (obj) { | ||
return Array.isArray(obj) | ||
} | ||
exports.isArray = Array.isArray | ||
@@ -204,0 +202,0 @@ /** |
@@ -80,9 +80,8 @@ var _ = require('./index') | ||
* @param {Object} options | ||
* @param {Boolean} hasAttrs | ||
* @return {String|undefined} | ||
*/ | ||
var commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/ | ||
var tableElementsRE = /^caption|colgroup|thead|tfoot|tbody|tr|td|th$/ | ||
exports.checkComponent = function (el, options) { | ||
exports.commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/ | ||
exports.checkComponent = function (el, options, hasAttrs) { | ||
var tag = el.tagName.toLowerCase() | ||
@@ -95,3 +94,3 @@ if (tag === 'component') { | ||
} else if ( | ||
!commonTagRE.test(tag) && | ||
!exports.commonTagRE.test(tag) && | ||
_.resolveAsset(options, 'components', tag) | ||
@@ -101,3 +100,3 @@ ) { | ||
} else if ( | ||
tableElementsRE.test(tag) && | ||
hasAttrs && | ||
(tag = _.attr(el, 'component')) | ||
@@ -104,0 +103,0 @@ ) { |
@@ -68,14 +68,16 @@ var _ = require('./index') | ||
} | ||
} else { | ||
// instance merge, return raw object | ||
var instanceData = typeof childVal === 'function' | ||
? childVal.call(vm) | ||
: childVal | ||
var defaultData = typeof parentVal === 'function' | ||
? parentVal.call(vm) | ||
: undefined | ||
if (instanceData) { | ||
return mergeData(instanceData, defaultData) | ||
} else { | ||
return defaultData | ||
} else if (parentVal || childVal) { | ||
return function mergedInstanceDataFn () { | ||
// instance merge | ||
var instanceData = typeof childVal === 'function' | ||
? childVal.call(vm) | ||
: childVal | ||
var defaultData = typeof parentVal === 'function' | ||
? parentVal.call(vm) | ||
: undefined | ||
if (instanceData) { | ||
return mergeData(instanceData, defaultData) | ||
} else { | ||
return defaultData | ||
} | ||
} | ||
@@ -151,2 +153,3 @@ } | ||
strats.components = | ||
strats.partials = | ||
strats.elementDirectives = function (parentVal, childVal) { | ||
@@ -219,2 +222,8 @@ var res = Object.create(parentVal) | ||
for (var key in components) { | ||
if (_.commonTagRE.test(key)) { | ||
_.warn( | ||
'Do not use built-in HTML elements as component ' + | ||
'name: ' + key | ||
) | ||
} | ||
def = components[key] | ||
@@ -281,2 +290,2 @@ if (_.isPlainObject(def)) { | ||
return asset | ||
} | ||
} |
@@ -38,9 +38,9 @@ var _ = require('./util') | ||
Vue.options = { | ||
replace: true, | ||
directives: require('./directives'), | ||
elementDirectives: require('./element-directives'), | ||
filters: require('./filters'), | ||
transitions: {}, | ||
components: {}, | ||
elementDirectives: { | ||
content: require('./compiler/content') | ||
} | ||
partials: {} | ||
} | ||
@@ -90,2 +90,2 @@ | ||
module.exports = _.Vue = Vue | ||
module.exports = _.Vue = Vue |
@@ -21,3 +21,2 @@ var _ = require('./util') | ||
* - {Boolean} user | ||
* - {Boolean} sync | ||
* - {Function} [preProcess] | ||
@@ -39,3 +38,2 @@ * @constructor | ||
this.twoWay = !!options.twoWay | ||
this.sync = !!options.sync | ||
this.filters = options.filters | ||
@@ -93,3 +91,7 @@ this.preProcess = options.preProcess | ||
'Error when evaluating expression "' + | ||
this.expression + '"', e | ||
this.expression + '". ' + | ||
(config.debug | ||
? '' : | ||
'Turn on debug mode to see stack trace.' | ||
), e | ||
) | ||
@@ -168,3 +170,3 @@ } | ||
p.update = function () { | ||
if (this.sync || !config.async) { | ||
if (!config.async) { | ||
this.run() | ||
@@ -186,3 +188,3 @@ } else { | ||
value !== this.value || | ||
Array.isArray(value) || | ||
_.isArray(value) || | ||
this.deep | ||
@@ -189,0 +191,0 @@ ) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
40
0
506509
20
71
16959