Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue

Package Overview
Dependencies
Maintainers
1
Versions
530
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue - npm Package Compare versions

Comparing version 0.12.8 to 0.12.9

2

package.json
{
"name": "vue",
"version": "0.12.8",
"version": "0.12.9",
"author": "Evan You <yyx990803@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -104,3 +104,3 @@ var _ = require('../util')

if (
this._isBlock &&
this._isFragment &&
!this._blockFragment.hasChildNodes()

@@ -143,3 +143,3 @@ ) {

!_.inDoc(vm.$el)
if (vm._isBlock) {
if (vm._isFragment) {
blockOp(vm, target, op, cb)

@@ -156,3 +156,3 @@ } else {

/**
* Execute a transition operation on a block instance,
* Execute a transition operation on a fragment instance,
* iterating through all its block nodes.

@@ -167,4 +167,4 @@ *

function blockOp (vm, target, op, cb) {
var current = vm._blockStart
var end = vm._blockEnd
var current = vm._fragmentStart
var end = vm._fragmentEnd
var next

@@ -171,0 +171,0 @@ while (next !== end) {

@@ -13,4 +13,4 @@ var _ = require('./util')

var has = {}
var circular = {}
var waiting = false
var flushing = false
var internalQueueDepleted = false

@@ -26,11 +26,11 @@

has = {}
waiting = flushing = internalQueueDepleted = false
circular = {}
waiting = internalQueueDepleted = false
}
/**
* Flush both queues and run the jobs.
* Flush both queues and run the watchers.
*/
function flush () {
flushing = true
run(queue)

@@ -43,3 +43,3 @@ internalQueueDepleted = true

/**
* Run the jobs in a single queue.
* Run the watchers in a single queue.
*

@@ -50,6 +50,20 @@ * @param {Array} queue

function run (queue) {
// do not cache length because more jobs might be pushed
// as we run existing jobs
// do not cache length because more watchers might be pushed
// as we run existing watchers
for (var i = 0; i < queue.length; i++) {
queue[i].run()
var watcher = queue[i]
var id = watcher.id
has[id] = null
watcher.run()
// in dev build, check and stop circular updates.
if (process.env.NODE_ENV !== 'production' && has[id] != null) {
circular[id] = (circular[id] || 0) + 1
if (circular[id] > config._maxUpdateCount) {
queue.splice(has[id], 1)
_.warn(
'You may have an infinite update loop for watcher ' +
'with expression: ' + watcher.expression
)
}
}
}

@@ -59,37 +73,26 @@ }

/**
* Push a job into the job queue.
* Push a watcher into the watcher queue.
* Jobs with duplicate IDs will be skipped unless it's
* pushed when the queue is being flushed.
*
* @param {Object} job
* @param {Watcher} watcher
* properties:
* - {String|Number} id
* - {Function} run
* - {Number} id
* - {Function} run
*/
exports.push = function (job) {
var id = job.id
if (!id || !has[id] || flushing) {
if (!has[id]) {
has[id] = 1
} else {
has[id]++
// detect possible infinite update loops
if (has[id] > config._maxUpdateCount) {
process.env.NODE_ENV !== 'production' && _.warn(
'You may have an infinite update loop for the ' +
'watcher with expression: "' + job.expression + '".'
)
return
}
}
// A user watcher callback could trigger another
// directive update during the flushing; at that time
// the directive queue would already have been run, so
// we call that update immediately as it is pushed.
if (flushing && !job.user && internalQueueDepleted) {
job.run()
exports.push = function (watcher) {
var id = watcher.id
if (has[id] == null) {
// if an internal watcher is pushed, but the internal
// queue is already depleted, we run it immediately.
if (internalQueueDepleted && !watcher.user) {
watcher.run()
return
}
;(job.user ? userQueue : queue).push(job)
// push watcher into appropriate queue
var q = watcher.user ? userQueue : queue
has[id] = q.length
q.push(watcher)
// queue the flush
if (!waiting) {

@@ -96,0 +99,0 @@ waiting = true

@@ -18,3 +18,3 @@ /**

this.head = this.tail = undefined
this._keymap = {}
this._keymap = Object.create(null)
}

@@ -21,0 +21,0 @@

@@ -141,5 +141,10 @@ var _ = require('../util')

// literal, cast it and just set once
value = options.type === Boolean && prop.raw === ''
var raw = prop.raw
value = options.type === Boolean && raw === ''
? true
: _.toBoolean(_.toNumber(prop.raw))
// do not cast emptry string.
// _.toNumber casts empty string to 0.
: raw.trim()
? _.toBoolean(_.toNumber(raw))
: raw
_.initProp(vm, prop, value)

@@ -159,9 +164,8 @@ }

function getDefault (options) {
// absent boolean value
if (options.type === Boolean) {
return false
}
// no default, return undefined
if (!options.hasOwnProperty('default')) {
return
// absent boolean value defaults to false
return options.type === Boolean
? false
: undefined
}

@@ -168,0 +172,0 @@ var def = options.default

@@ -149,3 +149,3 @@ var _ = require('../util')

*
* If this is a block instance, we only need to compile 1.
* If this is a fragment instance, we only need to compile 1.
*

@@ -169,3 +169,3 @@ * This function does compile and link at the same time,

// only need to compile other attributes for
// non-block instances
// non-fragment instances
if (el.nodeType !== 11) {

@@ -185,3 +185,3 @@ // for components, container and replacer need to be

// non-component, just compile as a normal element.
replacerLinkFn = compileDirectives(el, options)
replacerLinkFn = compileDirectives(el.attributes, options)
}

@@ -254,3 +254,3 @@ }

if (!linkFn && hasAttrs) {
linkFn = compileDirectives(el, options)
linkFn = compileDirectives(el.attributes, options)
}

@@ -508,5 +508,3 @@ // if the element is a textarea, we need to interpolate

*
* @param {Element|Object} elOrAttrs
* - could be an object of already-extracted
* container attributes.
* @param {Array|NamedNodeMap} attrs
* @param {Object} options

@@ -516,6 +514,3 @@ * @return {Function}

function compileDirectives (elOrAttrs, options) {
var attrs = _.isPlainObject(elOrAttrs)
? mapToList(elOrAttrs)
: elOrAttrs.attributes
function compileDirectives (attrs, options) {
var i = attrs.length

@@ -556,20 +551,2 @@ var dirs = []

/**
* Convert a map (Object) of attributes to an Array.
*
* @param {Object} map
* @return {Array}
*/
function mapToList (map) {
var list = []
for (var key in map) {
list.push({
name: key,
value: map[key]
})
}
return list
}
/**
* Build a link function for all directives on a single node.

@@ -576,0 +553,0 @@ *

@@ -27,3 +27,3 @@ var _ = require('../util')

// for template tags, what we want is its content as
// a documentFragment (for block instances)
// a documentFragment (for fragment instances)
if (_.isTemplate(el)) {

@@ -42,3 +42,3 @@ el = templateParser.parse(el)

if (el instanceof DocumentFragment) {
// anchors for block instance
// anchors for fragment instance
// passing in `persist: true` to avoid them being

@@ -76,2 +76,5 @@ // discarded by IE during template cloning

}
// there are many cases where the instance must
// become a fragment instance: basically anything that
// can create more than 1 root nodes.
if (

@@ -82,8 +85,9 @@ // multi-children template

replacer.nodeType !== 1 ||
// when root node is <component>, is an element
// directive, or has v-repeat, the instance could
// end up having multiple top-level nodes, thus
// becoming a block instance.
// single nested component
tag === 'component' ||
_.resolveAsset(options, 'components', tag) ||
replacer.hasAttribute(config.prefix + 'component') ||
// element directive
_.resolveAsset(options, 'elementDirectives', tag) ||
// repeat block
replacer.hasAttribute(config.prefix + 'repeat')

@@ -109,7 +113,7 @@ ) {

/**
* Helper to extract a component container's attribute names
* into a map.
* Helper to extract a component container's attributes
* into a plain object array.
*
* @param {Element} el
* @return {Object}
* @return {Array}
*/

@@ -119,9 +123,3 @@

if (el.nodeType === 1 && el.hasAttributes()) {
var attrs = el.attributes
var res = {}
var i = attrs.length
while (i--) {
res[attrs[i].name] = attrs[i].value
}
return res
return _.toArray(el.attributes)
}

@@ -148,5 +146,6 @@ }

} else if (name === 'class') {
to.className = to.className + ' ' + value
value = to.getAttribute(name) + ' ' + value
to.setAttribute(name, value)
}
}
}

@@ -21,2 +21,9 @@ module.exports = {

/**
* Strict mode.
* Disables asset lookup in the view parent chain.
*/
strict: false,
/**
* Whether to suppress warnings.

@@ -23,0 +30,0 @@ *

@@ -169,2 +169,3 @@ var _ = require('./util')

this.el.removeAttribute(name)
param = this.vm.$interpolate(param)
}

@@ -171,0 +172,0 @@ return param

@@ -38,3 +38,3 @@ // xlink

setAttr: function (attr, value) {
if (value || value === 0) {
if (value != null && value !== false) {
if (xlinkRE.test(attr)) {

@@ -48,7 +48,6 @@ this.el.setAttributeNS(xlinkNS, attr, value)

}
if (attr in this.el) {
this.el[attr] = value
if (attr === 'value' && 'value' in this.el) {
this.el.value = value
}
}
}
var _ = require('../util')
var config = require('../config')
var templateParser = require('../parsers/template')

@@ -32,3 +33,3 @@

// check ref
this.refID = _.attr(this.el, 'ref')
this.refID = this._checkParam(config.prefix + 'ref')
if (this.keepAlive) {

@@ -44,7 +45,7 @@ this.cache = {}

this._pendingCb =
this.ctorId =
this.Ctor = null
this.componentID =
this.Component = null
// if static, build right now.
if (!this._isDynamicLiteral) {
this.resolveCtor(this.expression, _.bind(this.initStatic, this))
this.resolveComponent(this.expression, _.bind(this.initStatic, this))
} else {

@@ -56,6 +57,4 @@ // check dynamic component params

process.env.NODE_ENV !== 'production' && _.warn(
'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.'
'cannot mount component "' + this.expression + '" ' +
'on already mounted element: ' + this.el
)

@@ -111,3 +110,3 @@ }

} else {
this.resolveCtor(value, _.bind(function () {
this.resolveComponent(value, _.bind(function () {
this.unbuild(true)

@@ -134,7 +133,7 @@ var newComponent = this.build(data)

resolveCtor: function (id, cb) {
resolveComponent: function (id, cb) {
var self = this
this._pendingCb = _.cancellable(function (ctor) {
self.ctorId = id
self.Ctor = ctor
this._pendingCb = _.cancellable(function (component) {
self.componentID = id
self.Component = component
cb()

@@ -169,3 +168,3 @@ })

if (this.keepAlive) {
var cached = this.cache[this.ctorId]
var cached = this.cache[this.componentID]
if (cached) {

@@ -175,3 +174,3 @@ return cached

}
if (this.Ctor) {
if (this.Component) {
var parent = this._host || this.vm

@@ -189,5 +188,5 @@ var el = templateParser.clone(this.el)

_context: this.vm
}, this.Ctor)
}, this.Component)
if (this.keepAlive) {
this.cache[this.ctorId] = child
this.cache[this.componentID] = child
}

@@ -194,0 +193,0 @@ return child

@@ -5,2 +5,4 @@ var _ = require('../util')

var transition = require('../transition')
var Cache = require('../cache')
var cache = new Cache(1000)

@@ -23,7 +25,13 @@ module.exports = {

// compile the nested partial
this.linker = compiler.compile(
this.template,
this.vm.$options,
true
)
var cacheId = (this.vm.constructor.cid || '') + el.outerHTML
this.linker = cache.get(cacheId)
if (!this.linker) {
this.linker = compiler.compile(
this.template,
this.vm.$options,
true, // partial
this._host // important
)
cache.put(cacheId, this.linker)
}
} else {

@@ -30,0 +38,0 @@ process.env.NODE_ENV !== 'production' && _.warn(

var _ = require('../util')
var config = require('../config')
var isObject = _.isObject

@@ -31,2 +32,3 @@ var isPlainObject = _.isPlainObject

this.id = '__v_repeat_' + (++uid)
// setup anchor nodes

@@ -37,2 +39,3 @@ this.start = _.createAnchor('v-repeat-start')

_.before(this.start, this.end)
// check if this is a block repeat

@@ -42,11 +45,5 @@ this.template = _.isTemplate(this.el)

: this.el
// check other directives that need to be handled
// at v-repeat level
this.checkIf()
this.checkRef()
this.checkComponent()
// check for trackby param
this.idKey =
this._checkParam('track-by') ||
this._checkParam('trackby') // 0.11.0 compat
this.idKey = this._checkParam('track-by')
// check for transition stagger

@@ -56,3 +53,15 @@ var stagger = +this._checkParam('stagger')

this.leaveStagger = +this._checkParam('leave-stagger') || stagger
// check for v-ref/v-el
this.refID = this._checkParam(config.prefix + 'ref')
this.elID = this._checkParam(config.prefix + 'el')
// check other directives that need to be handled
// at v-repeat level
this.checkIf()
this.checkComponent()
// create cache object
this.cache = Object.create(null)
// some helpful tips...

@@ -86,17 +95,2 @@ /* istanbul ignore if */

/**
* Check if v-ref/ v-el is also present.
*/
checkRef: function () {
var refID = _.attr(this.el, 'ref')
this.refID = refID
? this.vm.$interpolate(refID)
: null
var elId = _.attr(this.el, 'el')
this.elId = elId
? this.vm.$interpolate(elId)
: null
},
/**
* Check the component constructor to use for repeated

@@ -113,5 +107,5 @@ * instances. If static we resolve it now, otherwise it

// default constructor
this.Ctor = _.Vue
this.Component = _.Vue
// inline repeats should inherit
this.inherit = true
this.inline = true
// important: transclude with no options, just

@@ -124,3 +118,3 @@ // to ensure block start and block end

} else {
this.Ctor = null
this.Component = null
this.asComponent = true

@@ -135,4 +129,4 @@ // check inline-template

// dynamic component to be resolved later
var ctorExp = textParser.tokensToExp(tokens)
this.ctorGetter = expParser.parse(ctorExp).get
var componentExp = textParser.tokensToExp(tokens)
this.componentGetter = expParser.parse(componentExp).get
} else {

@@ -148,7 +142,7 @@ // static

this.componentState = PENDING
this.vm._resolveComponent(this.componentId, _.bind(function (Ctor) {
this.vm._resolveComponent(this.componentId, _.bind(function (Component) {
if (this.componentState === ABORTED) {
return
}
this.Ctor = Ctor
this.Component = Component
this.componentState = RESOLVED

@@ -183,8 +177,8 @@ this.realUpdate(this.pendingData)

}
var id = this.ctorGetter.call(context, context)
var Ctor = _.resolveAsset(this.vm.$options, 'components', id)
var id = this.componentGetter.call(context, context)
var Component = _.resolveAsset(this.vm.$options, 'components', id)
if (process.env.NODE_ENV !== 'production') {
_.assertAsset(Ctor, 'component', id)
_.assertAsset(Component, 'component', id)
}
if (!Ctor.options) {
if (!Component.options) {
process.env.NODE_ENV !== 'production' && _.warn(

@@ -196,3 +190,3 @@ 'Async resolution is not supported for v-repeat ' +

}
return Ctor
return Component
},

@@ -240,4 +234,4 @@

}
if (this.elId) {
this.vm.$$[this.elId] = this.vms.map(function (vm) {
if (this.elID) {
this.vm.$$[this.elID] = this.vms.map(function (vm) {
return vm.$el

@@ -336,3 +330,3 @@ })

? targetPrev._staggerAnchor
: targetPrev._blockEnd || targetPrev.$el
: targetPrev._fragmentEnd || targetPrev.$el
: start

@@ -381,3 +375,3 @@ if (vm._reused && !vm._staggerCb) {

// resolve constructor
var Ctor = this.Ctor || this.resolveDynamicComponent(data, meta)
var Component = this.Component || this.resolveDynamicComponent(data, meta)
var parent = this._host || this.vm

@@ -387,3 +381,3 @@ var vm = parent.$addChild({

data: data,
inherit: this.inherit,
inherit: this.inline,
template: this.inlineTemplate,

@@ -393,7 +387,7 @@ // repeater meta, e.g. $index, $key

// mark this as an inline-repeat instance
_repeat: this.inherit,
_repeat: this.inline,
// is this a component?
_asComponent: this.asComponent,
// linker cachable if no inline-template
_linkerCachable: !this.inlineTemplate && Ctor !== _.Vue,
_linkerCachable: !this.inlineTemplate && Component !== _.Vue,
// pre-compiled linker for simple repeats

@@ -405,3 +399,3 @@ _linkFn: this._linkFn,

_context: this.vm
}, Ctor)
}, Component)
// cache instance

@@ -412,8 +406,4 @@ if (needCache) {

// sync back changes for two-way bindings of primitive values
var type = typeof raw
var dir = this
if (
this.rawType === 'object' &&
(type === 'string' || type === 'number')
) {
if (this.rawType === 'object' && isPrimitive(raw)) {
vm.$watch(alias || '$value', function (val) {

@@ -767,1 +757,17 @@ if (dir.filters) {

}
/**
* Check if a value is a primitive one:
* String, Number, Boolean, null or undefined.
*
* @param {*} value
* @return {Boolean}
*/
function isPrimitive (value) {
var type = typeof value
return value == null ||
type === 'string' ||
type === 'number' ||
type === 'boolean'
}
var _ = require('../util')
var clone = require('../parsers/template').clone

@@ -25,3 +26,3 @@ // This is the elementDirective that handles <content>

var context = host._context
var selector = this.el.getAttribute('select')
var selector = this._checkParam('select')
if (!selector) {

@@ -48,3 +49,2 @@ // Default content

// select content
selector = vm.$interpolate(selector)
var nodes = raw.querySelectorAll(selector)

@@ -106,6 +106,6 @@ if (nodes.length) {

if (main && !node.__v_selected) {
frag.appendChild(node.cloneNode(true))
frag.appendChild(clone(node))
} else if (!main && node.parentNode === parent) {
node.__v_selected = true
frag.appendChild(node.cloneNode(true))
frag.appendChild(clone(node))
}

@@ -112,0 +112,0 @@ }

@@ -79,8 +79,8 @@ var _ = require('../util')

if (el instanceof DocumentFragment) {
this._isBlock = true
this.$el = this._blockStart = el.firstChild
this._blockEnd = el.lastChild
this._isFragment = true
this.$el = this._fragmentStart = el.firstChild
this._fragmentEnd = el.lastChild
// set persisted text anchors to empty
if (this._blockStart.nodeType === 3) {
this._blockStart.data = this._blockEnd.data = ''
if (this._fragmentStart.nodeType === 3) {
this._fragmentStart.data = this._fragmentEnd.data = ''
}

@@ -87,0 +87,0 @@ this._blockFragment = el

@@ -36,6 +36,6 @@ var mergeOptions = require('../util').mergeOptions

// block instance properties
this._isBlock = false
this._blockStart = // @type {CommentNode}
this._blockEnd = null // @type {CommentNode}
// fragment instance properties
this._isFragment = false
this._fragmentStart = // @type {CommentNode}
this._fragmentEnd = null // @type {CommentNode}

@@ -42,0 +42,0 @@ // lifecycle state

@@ -58,2 +58,5 @@ var _ = require('../util')

}
if (!factory) {
return
}
// async component factory

@@ -60,0 +63,0 @@ if (!factory.options) {

@@ -176,2 +176,5 @@ var _ = require('../util')

var res = node.cloneNode(true)
if (!node.querySelectorAll) {
return res
}
var i, original, cloned

@@ -186,3 +189,3 @@ /* istanbul ignore if */

cloned[i].parentNode.replaceChild(
original[i].cloneNode(true),
exports.clone(original[i]),
cloned[i]

@@ -234,3 +237,3 @@ )

return clone
? template.cloneNode(true)
? exports.clone(template)
: template

@@ -237,0 +240,0 @@ }

@@ -243,3 +243,3 @@ var _ = require('./index')

* This is used in a number of scenarios:
* - block instance
* - fragment instance
* - v-html

@@ -246,0 +246,0 @@ * - v-if

@@ -28,4 +28,4 @@ /**

/**
* Check and convert possible numeric numbers before
* setting back to data
* Check and convert possible numeric strings to numbers
* before setting back to data
*

@@ -37,8 +37,10 @@ * @param {*} value

exports.toNumber = function (value) {
return (
isNaN(value) ||
value === null ||
typeof value === 'boolean'
) ? value
: Number(value)
if (typeof value !== 'string') {
return value
} else {
var parsed = Number(value)
return isNaN(parsed)
? value
: parsed
}
}

@@ -45,0 +47,0 @@

@@ -343,8 +343,12 @@ var _ = require('./index')

exports.resolveAsset = function resolve (options, type, id) {
var asset = options[type][id]
while (!config.strict && !asset && options._parent) {
var camelizedId = _.camelize(id)
var asset = options[type][id] || options[type][camelizedId]
while (
!asset && options._parent &&
(!config.strict || options._repeat)
) {
options = options._parent.$options
asset = options[type][id]
asset = options[type][id] || options[type][camelizedId]
}
return asset
}

@@ -30,3 +30,3 @@ var _ = require('./util')

vm._watchers.push(this)
this.expression = isFn ? '' : expOrFn
this.expression = isFn ? expOrFn.toString() : expOrFn
this.cb = cb

@@ -33,0 +33,0 @@ this.id = ++uid // uid for batching

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc