/*! * Vue.js v0.12.12 * (c) 2015 Evan You * Released under the MIT License. */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define(factory); else if(typeof exports === 'object') exports["Vue"] = factory(); else root["Vue"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var extend = _.extend /** * The exposed Vue constructor. * * API conventions: * - public API methods/properties are prefiexed with `$` * - internal methods/properties are prefixed with `_` * - non-prefixed properties are assumed to be proxied user * data. * * @constructor * @param {Object} [options] * @public */ function Vue (options) { this._init(options) } /** * Mixin global API */ extend(Vue, __webpack_require__(9)) /** * Vue and every constructor that extends Vue has an * associated options object, which can be accessed during * compilation steps as `this.constructor.options`. * * These can be seen as the default options of every * Vue instance. */ Vue.options = { replace: true, directives: __webpack_require__(25), elementDirectives: __webpack_require__(47), filters: __webpack_require__(50), transitions: {}, components: {}, partials: {} } /** * Build up the prototype */ var p = Vue.prototype /** * $data has a setter which does a bunch of * teardown/setup work */ Object.defineProperty(p, '$data', { get: function () { return this._data }, set: function (newData) { if (newData !== this._data) { this._setData(newData) } } }) /** * Mixin internal instance methods */ extend(p, __webpack_require__(52)) extend(p, __webpack_require__(53)) extend(p, __webpack_require__(54)) extend(p, __webpack_require__(58)) extend(p, __webpack_require__(60)) /** * Mixin public API methods */ extend(p, __webpack_require__(61)) extend(p, __webpack_require__(62)) extend(p, __webpack_require__(63)) extend(p, __webpack_require__(64)) extend(p, __webpack_require__(65)) module.exports = _.Vue = Vue /***/ }, /* 1 */ /***/ function(module, exports, __webpack_require__) { var lang = __webpack_require__(2) var extend = lang.extend extend(exports, lang) extend(exports, __webpack_require__(3)) extend(exports, __webpack_require__(4)) extend(exports, __webpack_require__(6)) extend(exports, __webpack_require__(7)) extend(exports, __webpack_require__(8)) /***/ }, /* 2 */ /***/ function(module, exports) { /** * Check is a string starts with $ or _ * * @param {String} str * @return {Boolean} */ exports.isReserved = function (str) { var c = (str + '').charCodeAt(0) return c === 0x24 || c === 0x5F } /** * Guard text output, make sure undefined outputs * empty string * * @param {*} value * @return {String} */ exports.toString = function (value) { return value == null ? '' : value.toString() } /** * Check and convert possible numeric strings to numbers * before setting back to data * * @param {*} value * @return {*|Number} */ exports.toNumber = function (value) { if (typeof value !== 'string') { return value } else { var parsed = Number(value) return isNaN(parsed) ? value : parsed } } /** * Convert string boolean literals into real booleans. * * @param {*} value * @return {*|Boolean} */ exports.toBoolean = function (value) { return value === 'true' ? true : value === 'false' ? false : value } /** * Strip quotes from a string * * @param {String} str * @return {String | false} */ exports.stripQuotes = function (str) { var a = str.charCodeAt(0) var b = str.charCodeAt(str.length - 1) return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : false } /** * Camelize a hyphen-delmited string. * * @param {String} str * @return {String} */ exports.camelize = function (str) { return str.replace(/-(\w)/g, toUpper) } function toUpper (_, c) { return c ? c.toUpperCase() : '' } /** * Hyphenate a camelCase string. * * @param {String} str * @return {String} */ exports.hyphenate = function (str) { return str .replace(/([a-z\d])([A-Z])/g, '$1-$2') .toLowerCase() } /** * Converts hyphen/underscore/slash delimitered names into * camelized classNames. * * e.g. my-component => MyComponent * some_else => SomeElse * some/comp => SomeComp * * @param {String} str * @return {String} */ var classifyRE = /(?:^|[-_\/])(\w)/g exports.classify = function (str) { return str.replace(classifyRE, toUpper) } /** * Simple bind, faster than native * * @param {Function} fn * @param {Object} ctx * @return {Function} */ exports.bind = function (fn, ctx) { return function (a) { var l = arguments.length return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) } } /** * Convert an Array-like object to a real Array. * * @param {Array-like} list * @param {Number} [start] - start index * @return {Array} */ exports.toArray = function (list, start) { start = start || 0 var i = list.length - start var ret = new Array(i) while (i--) { ret[i] = list[i + start] } return ret } /** * Mix properties into target object. * * @param {Object} to * @param {Object} from */ exports.extend = function (to, from) { for (var key in from) { to[key] = from[key] } return to } /** * Quick object check - this is primarily used to tell * Objects from primitive values when we know the value * is a JSON-compliant type. * * @param {*} obj * @return {Boolean} */ exports.isObject = function (obj) { return obj !== null && typeof obj === 'object' } /** * Strict object type check. Only returns true * for plain JavaScript objects. * * @param {*} obj * @return {Boolean} */ var toString = Object.prototype.toString exports.isPlainObject = function (obj) { return toString.call(obj) === '[object Object]' } /** * Array type check. * * @param {*} obj * @return {Boolean} */ exports.isArray = Array.isArray /** * Define a non-enumerable property * * @param {Object} obj * @param {String} key * @param {*} val * @param {Boolean} [enumerable] */ exports.define = function (obj, key, val, enumerable) { Object.defineProperty(obj, key, { value: val, enumerable: !!enumerable, writable: true, configurable: true }) } /** * Debounce a function so it only gets called after the * input stops arriving after the given wait period. * * @param {Function} func * @param {Number} wait * @return {Function} - the debounced function */ exports.debounce = function (func, wait) { var timeout, args, context, timestamp, result var later = function () { var last = Date.now() - timestamp if (last < wait && last >= 0) { timeout = setTimeout(later, wait - last) } else { timeout = null result = func.apply(context, args) if (!timeout) context = args = null } } return function () { context = this args = arguments timestamp = Date.now() if (!timeout) { timeout = setTimeout(later, wait) } return result } } /** * Manual indexOf because it's slightly faster than * native. * * @param {Array} arr * @param {*} obj */ exports.indexOf = function (arr, obj) { for (var i = 0, l = arr.length; i < l; i++) { if (arr[i] === obj) return i } return -1 } /** * Make a cancellable version of an async callback. * * @param {Function} fn * @return {Function} */ exports.cancellable = function (fn) { var cb = function () { if (!cb.cancelled) { return fn.apply(this, arguments) } } cb.cancel = function () { cb.cancelled = true } return cb } /** * Check if two values are loosely equal - that is, * if they are plain objects, do they have the same shape? * * @param {*} a * @param {*} b * @return {Boolean} */ exports.looseEqual = function (a, b) { /* eslint-disable eqeqeq */ return a == b || ( exports.isObject(a) && exports.isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false ) /* eslint-enable eqeqeq */ } /***/ }, /* 3 */ /***/ function(module, exports) { // can we use __proto__? exports.hasProto = '__proto__' in {} // Browser environment sniffing var inBrowser = exports.inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]' exports.isIE9 = inBrowser && navigator.userAgent.toLowerCase().indexOf('msie 9.0') > 0 exports.isAndroid = inBrowser && navigator.userAgent.toLowerCase().indexOf('android') > 0 // Transition property/event sniffing if (inBrowser && !exports.isIE9) { var isWebkitTrans = window.ontransitionend === undefined && window.onwebkittransitionend !== undefined var isWebkitAnim = window.onanimationend === undefined && window.onwebkitanimationend !== undefined exports.transitionProp = isWebkitTrans ? 'WebkitTransition' : 'transition' exports.transitionEndEvent = isWebkitTrans ? 'webkitTransitionEnd' : 'transitionend' exports.animationProp = isWebkitAnim ? 'WebkitAnimation' : 'animation' exports.animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend' } /** * Defer a task to execute it asynchronously. Ideally this * should be executed as a microtask, so we leverage * MutationObserver if it's available, and fallback to * setTimeout(0). * * @param {Function} cb * @param {Object} ctx */ exports.nextTick = (function () { var callbacks = [] var pending = false var timerFunc function nextTickHandler () { pending = false var copies = callbacks.slice(0) callbacks = [] for (var i = 0; i < copies.length; i++) { copies[i]() } } /* istanbul ignore if */ if (typeof MutationObserver !== 'undefined') { var counter = 1 var observer = new MutationObserver(nextTickHandler) var textNode = document.createTextNode(counter) observer.observe(textNode, { characterData: true }) timerFunc = function () { counter = (counter + 1) % 2 textNode.data = counter } } else { timerFunc = setTimeout } return function (cb, ctx) { var func = ctx ? function () { cb.call(ctx) } : cb callbacks.push(func) if (pending) return pending = true timerFunc(nextTickHandler, 0) } })() /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var config = __webpack_require__(5) /** * Query an element selector if it's not an element already. * * @param {String|Element} el * @return {Element} */ exports.query = function (el) { if (typeof el === 'string') { var selector = el el = document.querySelector(el) if (!el) { ("development") !== 'production' && _.warn( 'Cannot find element: ' + selector ) } } return el } /** * Check if a node is in the document. * Note: document.documentElement.contains should work here * but always returns false for comment nodes in phantomjs, * making unit tests difficult. This is fixed byy doing the * contains() check on the node's parentNode instead of * the node itself. * * @param {Node} node * @return {Boolean} */ exports.inDoc = function (node) { var doc = document.documentElement var parent = node && node.parentNode return doc === node || doc === parent || !!(parent && parent.nodeType === 1 && (doc.contains(parent))) } /** * Extract an attribute from a node. * * @param {Node} node * @param {String} attr */ exports.attr = function (node, attr) { attr = config.prefix + attr var val = node.getAttribute(attr) if (val !== null) { node.removeAttribute(attr) } return val } /** * Insert el before target * * @param {Element} el * @param {Element} target */ exports.before = function (el, target) { target.parentNode.insertBefore(el, target) } /** * Insert el after target * * @param {Element} el * @param {Element} target */ exports.after = function (el, target) { if (target.nextSibling) { exports.before(el, target.nextSibling) } else { target.parentNode.appendChild(el) } } /** * Remove el from DOM * * @param {Element} el */ exports.remove = function (el) { el.parentNode.removeChild(el) } /** * Prepend el to target * * @param {Element} el * @param {Element} target */ exports.prepend = function (el, target) { if (target.firstChild) { exports.before(el, target.firstChild) } else { target.appendChild(el) } } /** * Replace target with el * * @param {Element} target * @param {Element} el */ exports.replace = function (target, el) { var parent = target.parentNode if (parent) { parent.replaceChild(el, target) } } /** * Add event listener shorthand. * * @param {Element} el * @param {String} event * @param {Function} cb */ exports.on = function (el, event, cb) { el.addEventListener(event, cb) } /** * Remove event listener shorthand. * * @param {Element} el * @param {String} event * @param {Function} cb */ exports.off = function (el, event, cb) { el.removeEventListener(event, cb) } /** * Add class with compatibility for IE & SVG * * @param {Element} el * @param {Strong} cls */ exports.addClass = function (el, cls) { if (el.classList) { el.classList.add(cls) } else { var cur = ' ' + (el.getAttribute('class') || '') + ' ' if (cur.indexOf(' ' + cls + ' ') < 0) { el.setAttribute('class', (cur + cls).trim()) } } } /** * Remove class with compatibility for IE & SVG * * @param {Element} el * @param {Strong} cls */ exports.removeClass = function (el, cls) { if (el.classList) { el.classList.remove(cls) } else { var cur = ' ' + (el.getAttribute('class') || '') + ' ' var tar = ' ' + cls + ' ' while (cur.indexOf(tar) >= 0) { cur = cur.replace(tar, ' ') } el.setAttribute('class', cur.trim()) } } /** * Extract raw content inside an element into a temporary * container div * * @param {Element} el * @param {Boolean} asFragment * @return {Element} */ exports.extractContent = function (el, asFragment) { var child var rawContent /* istanbul ignore if */ if ( exports.isTemplate(el) && el.content instanceof DocumentFragment ) { el = el.content } if (el.hasChildNodes()) { exports.trimNode(el) rawContent = asFragment ? document.createDocumentFragment() : document.createElement('div') /* eslint-disable no-cond-assign */ while (child = el.firstChild) { /* eslint-enable no-cond-assign */ rawContent.appendChild(child) } } return rawContent } /** * Trim possible empty head/tail textNodes inside a parent. * * @param {Node} node */ exports.trimNode = function (node) { trim(node, node.firstChild) trim(node, node.lastChild) } function trim (parent, node) { if (node && node.nodeType === 3 && !node.data.trim()) { parent.removeChild(node) } } /** * Check if an element is a template tag. * Note if the template appears inside an SVG its tagName * will be in lowercase. * * @param {Element} el */ exports.isTemplate = function (el) { return el.tagName && el.tagName.toLowerCase() === 'template' } /** * Create an "anchor" for performing dom insertion/removals. * This is used in a number of scenarios: * - fragment instance * - v-html * - v-if * - component * - repeat * * @param {String} content * @param {Boolean} persist - IE trashes empty textNodes on * cloneNode(true), so in certain * cases the anchor needs to be * non-empty to be persisted in * templates. * @return {Comment|Text} */ exports.createAnchor = function (content, persist) { return config.debug ? document.createComment(content) : document.createTextNode(persist ? ' ' : '') } /***/ }, /* 5 */ /***/ function(module, exports) { module.exports = { /** * The prefix to look for when parsing directives. * * @type {String} */ prefix: 'v-', /** * Whether to print debug messages. * Also enables stack trace for warnings. * * @type {Boolean} */ debug: false, /** * Strict mode. * Disables asset lookup in the view parent chain. */ strict: false, /** * Whether to suppress warnings. * * @type {Boolean} */ silent: false, /** * Whether allow observer to alter data objects' * __proto__. * * @type {Boolean} */ proto: true, /** * Whether to parse mustache tags in templates. * * @type {Boolean} */ interpolate: true, /** * Whether to use async rendering. */ async: true, /** * Whether to warn against errors caught when evaluating * expressions. */ warnExpressionErrors: true, /** * Internal flag to indicate the delimiters have been * changed. * * @type {Boolean} */ _delimitersChanged: true, /** * List of asset types that a component can own. * * @type {Array} */ _assetTypes: [ 'component', 'directive', 'elementDirective', 'filter', 'transition', 'partial' ], /** * prop binding modes */ _propBindingModes: { ONE_WAY: 0, TWO_WAY: 1, ONE_TIME: 2 }, /** * Max circular updates allowed in a batcher flush cycle. */ _maxUpdateCount: 100 } /** * Interpolation delimiters. * We need to mark the changed flag so that the text parser * knows it needs to recompile the regex. * * @type {Array} */ var delimiters = ['{{', '}}'] Object.defineProperty(module.exports, 'delimiters', { get: function () { return delimiters }, set: function (val) { delimiters = val this._delimitersChanged = true } }) /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var config = __webpack_require__(5) var extend = _.extend /** * Option overwriting strategies are functions that handle * how to merge a parent option value and a child option * value into the final value. * * All strategy functions follow the same signature: * * @param {*} parentVal * @param {*} childVal * @param {Vue} [vm] */ var strats = Object.create(null) /** * Helper that recursively merges two data objects together. */ function mergeData (to, from) { var key, toVal, fromVal for (key in from) { toVal = to[key] fromVal = from[key] if (!to.hasOwnProperty(key)) { to.$add(key, fromVal) } else if (_.isObject(toVal) && _.isObject(fromVal)) { mergeData(toVal, fromVal) } } return to } /** * Data */ strats.data = function (parentVal, childVal, vm) { if (!vm) { // in a Vue.extend merge, both should be functions if (!childVal) { return parentVal } if (typeof childVal !== 'function') { ("development") !== 'production' && _.warn( 'The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.' ) return parentVal } if (!parentVal) { return childVal } // when parentVal & childVal are both present, // we need to return a function that returns the // merged result of both functions... no need to // check if parentVal is a function here because // it has to be a function to pass previous merges. return function mergedDataFn () { return mergeData( childVal.call(this), parentVal.call(this) ) } } 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 } } } } /** * El */ strats.el = function (parentVal, childVal, vm) { if (!vm && childVal && typeof childVal !== 'function') { ("development") !== 'production' && _.warn( 'The "el" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.' ) return } var ret = childVal || parentVal // invoke the element factory if this is instance merge return vm && typeof ret === 'function' ? ret.call(vm) : ret } /** * Hooks and param attributes are merged as arrays. */ strats.created = strats.ready = strats.attached = strats.detached = strats.beforeCompile = strats.compiled = strats.beforeDestroy = strats.destroyed = strats.props = function (parentVal, childVal) { return childVal ? parentVal ? parentVal.concat(childVal) : _.isArray(childVal) ? childVal : [childVal] : parentVal } /** * 0.11 deprecation warning */ strats.paramAttributes = function () { /* istanbul ignore next */ ("development") !== 'production' && _.warn( '"paramAttributes" option has been deprecated in 0.12. ' + 'Use "props" instead.' ) } /** * Assets * * When a vm is present (instance creation), we need to do * a three-way merge between constructor options, instance * options and parent options. */ function mergeAssets (parentVal, childVal) { var res = Object.create(parentVal) return childVal ? extend(res, guardArrayAssets(childVal)) : res } config._assetTypes.forEach(function (type) { strats[type + 's'] = mergeAssets }) /** * Events & Watchers. * * Events & watchers hashes should not overwrite one * another, so we merge them as arrays. */ strats.watch = strats.events = function (parentVal, childVal) { if (!childVal) return parentVal if (!parentVal) return childVal var ret = {} extend(ret, parentVal) for (var key in childVal) { var parent = ret[key] var child = childVal[key] if (parent && !_.isArray(parent)) { parent = [parent] } ret[key] = parent ? parent.concat(child) : [child] } return ret } /** * Other object hashes. */ strats.methods = strats.computed = function (parentVal, childVal) { if (!childVal) return parentVal if (!parentVal) return childVal var ret = Object.create(parentVal) extend(ret, childVal) return ret } /** * Default strategy. */ var defaultStrat = function (parentVal, childVal) { return childVal === undefined ? parentVal : childVal } /** * Make sure component options get converted to actual * constructors. * * @param {Object} options */ function guardComponents (options) { if (options.components) { var components = options.components = guardArrayAssets(options.components) var def var ids = Object.keys(components) for (var i = 0, l = ids.length; i < l; i++) { var key = ids[i] if (_.commonTagRE.test(key)) { ("development") !== 'production' && _.warn( 'Do not use built-in HTML elements as component ' + 'id: ' + key ) continue } def = components[key] if (_.isPlainObject(def)) { def.id = def.id || key components[key] = def._Ctor || (def._Ctor = _.Vue.extend(def)) } } } } /** * Ensure all props option syntax are normalized into the * Object-based format. * * @param {Object} options */ function guardProps (options) { var props = options.props if (_.isPlainObject(props)) { options.props = Object.keys(props).map(function (key) { var val = props[key] if (!_.isPlainObject(val)) { val = { type: val } } val.name = key return val }) } else if (_.isArray(props)) { options.props = props.map(function (prop) { return typeof prop === 'string' ? { name: prop } : prop }) } } /** * Guard an Array-format assets option and converted it * into the key-value Object format. * * @param {Object|Array} assets * @return {Object} */ function guardArrayAssets (assets) { if (_.isArray(assets)) { var res = {} var i = assets.length var asset while (i--) { asset = assets[i] var id = asset.id || (asset.options && asset.options.id) if (!id) { ("development") !== 'production' && _.warn( 'Array-syntax assets must provide an id field.' ) } else { res[id] = asset } } return res } return assets } /** * Merge two option objects into a new one. * Core utility used in both instantiation and inheritance. * * @param {Object} parent * @param {Object} child * @param {Vue} [vm] - if vm is present, indicates this is * an instantiation merge. */ exports.mergeOptions = function merge (parent, child, vm) { guardComponents(child) guardProps(child) var options = {} var key if (child.mixins) { for (var i = 0, l = child.mixins.length; i < l; i++) { parent = merge(parent, child.mixins[i], vm) } } for (key in parent) { mergeField(key) } for (key in child) { if (!(parent.hasOwnProperty(key))) { mergeField(key) } } function mergeField (key) { var strat = strats[key] || defaultStrat options[key] = strat(parent[key], child[key], vm, key) } return options } /** * Resolve an asset. * This function is used because child instances need access * to assets defined in its ancestor chain. * * @param {Object} options * @param {String} type * @param {String} id * @return {Object|Function} */ exports.resolveAsset = function resolve (options, type, id) { var camelizedId = _.camelize(id) var pascalizedId = camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1) var assets = options[type] var asset = assets[id] || assets[camelizedId] || assets[pascalizedId] while ( !asset && options._parent && (!config.strict || options._repeat) ) { options = (options._context || options._parent).$options assets = options[type] asset = assets[id] || assets[camelizedId] || assets[pascalizedId] } return asset } /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) /** * Check if an element is a component, if yes return its * component id. * * @param {Element} el * @param {Object} options * @return {String|undefined} */ exports.commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/ exports.checkComponent = function (el, options) { var tag = el.tagName.toLowerCase() if (tag === 'component') { // dynamic syntax var exp = el.getAttribute('is') el.removeAttribute('is') return exp } else if ( !exports.commonTagRE.test(tag) && _.resolveAsset(options, 'components', tag) ) { return tag /* eslint-disable no-cond-assign */ } else if (tag = _.attr(el, 'component')) { /* eslint-enable no-cond-assign */ return tag } } /** * Set a prop's initial value on a vm and its data object. * The vm may have inherit:true so we need to make sure * we don't accidentally overwrite parent value. * * @param {Vue} vm * @param {Object} prop * @param {*} value */ exports.initProp = function (vm, prop, value) { if (exports.assertProp(prop, value)) { var key = prop.path if (key in vm) { _.define(vm, key, value, true) } else { vm[key] = value } vm._data[key] = value } } /** * Assert whether a prop is valid. * * @param {Object} prop * @param {*} value */ exports.assertProp = function (prop, value) { // if a prop is not provided and is not required, // skip the check. if (prop.raw === null && !prop.required) { return true } var options = prop.options var type = options.type var valid = true var expectedType if (type) { if (type === String) { expectedType = 'string' valid = typeof value === expectedType } else if (type === Number) { expectedType = 'number' valid = typeof value === 'number' } else if (type === Boolean) { expectedType = 'boolean' valid = typeof value === 'boolean' } else if (type === Function) { expectedType = 'function' valid = typeof value === 'function' } else if (type === Object) { expectedType = 'object' valid = _.isPlainObject(value) } else if (type === Array) { expectedType = 'array' valid = _.isArray(value) } else { valid = value instanceof type } } if (!valid) { ("development") !== 'production' && _.warn( 'Invalid prop: type check failed for ' + prop.path + '="' + prop.raw + '".' + ' Expected ' + formatType(expectedType) + ', got ' + formatValue(value) + '.' ) return false } var validator = options.validator if (validator) { if (!validator.call(null, value)) { ("development") !== 'production' && _.warn( 'Invalid prop: custom validator check failed for ' + prop.path + '="' + prop.raw + '"' ) return false } } return true } function formatType (val) { return val ? val.charAt(0).toUpperCase() + val.slice(1) : 'custom type' } function formatValue (val) { return Object.prototype.toString.call(val).slice(8, -1) } /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { /** * Enable debug utilities. */ if (true) { var config = __webpack_require__(5) var hasConsole = typeof console !== 'undefined' /** * Log a message. * * @param {String} msg */ exports.log = function (msg) { if (hasConsole && config.debug) { console.log('[Vue info]: ' + msg) } } /** * We've got a problem here. * * @param {String} msg */ exports.warn = function (msg, e) { if (hasConsole && (!config.silent || config.debug)) { console.warn('[Vue warn]: ' + msg) /* istanbul ignore if */ if (config.debug) { console.warn((e || new Error('Warning Stack Trace')).stack) } } } /** * Assert asset exists */ exports.assertAsset = function (val, type, id) { /* istanbul ignore if */ if (type === 'directive') { if (id === 'with') { exports.warn( 'v-with has been deprecated in ^0.12.0. ' + 'Use props instead.' ) return } if (id === 'events') { exports.warn( 'v-events has been deprecated in ^0.12.0. ' + 'Pass down methods as callback props instead.' ) return } } if (!val) { exports.warn('Failed to resolve ' + type + ': ' + id) } } } /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var config = __webpack_require__(5) /** * Expose useful internals */ exports.util = _ exports.config = config exports.nextTick = _.nextTick exports.compiler = __webpack_require__(10) exports.parsers = { path: __webpack_require__(20), text: __webpack_require__(13), template: __webpack_require__(22), directive: __webpack_require__(15), expression: __webpack_require__(19) } /** * Each instance constructor, including Vue, has a unique * cid. This enables us to create wrapped "child * constructors" for prototypal inheritance and cache them. */ exports.cid = 0 var cid = 1 /** * Class inheritance * * @param {Object} extendOptions */ exports.extend = function (extendOptions) { extendOptions = extendOptions || {} var Super = this var Sub = createClass( extendOptions.name || Super.options.name || 'VueComponent' ) Sub.prototype = Object.create(Super.prototype) Sub.prototype.constructor = Sub Sub.cid = cid++ Sub.options = _.mergeOptions( Super.options, extendOptions ) Sub['super'] = Super // allow further extension Sub.extend = Super.extend // create asset registers, so extended classes // can have their private assets too. config._assetTypes.forEach(function (type) { Sub[type] = Super[type] }) return Sub } /** * A function that returns a sub-class constructor with the * given name. This gives us much nicer output when * logging instances in the console. * * @param {String} name * @return {Function} */ function createClass (name) { return new Function( 'return function ' + _.classify(name) + ' (options) { this._init(options) }' )() } /** * Plugin system * * @param {Object} plugin */ exports.use = function (plugin) { // additional parameters var args = _.toArray(arguments, 1) args.unshift(this) if (typeof plugin.install === 'function') { plugin.install.apply(plugin, args) } else { plugin.apply(null, args) } return this } /** * Create asset registration methods with the following * signature: * * @param {String} id * @param {*} definition */ config._assetTypes.forEach(function (type) { exports[type] = function (id, definition) { if (!definition) { return this.options[type + 's'][id] } else { if ( type === 'component' && _.isPlainObject(definition) ) { definition.name = id definition = _.Vue.extend(definition) } this.options[type + 's'][id] = definition } } }) /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) _.extend(exports, __webpack_require__(11)) _.extend(exports, __webpack_require__(24)) /***/ }, /* 11 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var compileProps = __webpack_require__(12) var config = __webpack_require__(5) var textParser = __webpack_require__(13) var dirParser = __webpack_require__(15) var templateParser = __webpack_require__(22) var resolveAsset = _.resolveAsset var componentDef = __webpack_require__(23) // terminal directives var terminalDirectives = [ 'repeat', 'if' ] /** * Compile a template and return a reusable composite link * function, which recursively contains more link functions * inside. This top level compile function would normally * be called on instance root nodes, but can also be used * for partial compilation if the partial argument is true. * * The returned composite link function, when called, will * return an unlink function that tearsdown all directives * created during the linking phase. * * @param {Element|DocumentFragment} el * @param {Object} options * @param {Boolean} partial * @return {Function} */ exports.compile = function (el, options, partial) { // link function for the node itself. var nodeLinkFn = partial || !options._asComponent ? compileNode(el, options) : null // link function for the childNodes var childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && el.tagName !== 'SCRIPT' && el.hasChildNodes() ? compileNodeList(el.childNodes, options) : null /** * A composite linker function to be called on a already * compiled piece of DOM, which instantiates all directive * instances. * * @param {Vue} vm * @param {Element|DocumentFragment} el * @param {Vue} [host] - host vm of transcluded content * @return {Function|undefined} */ return function compositeLinkFn (vm, el, host) { // cache childNodes before linking parent, fix #657 var childNodes = _.toArray(el.childNodes) // link var dirs = linkAndCapture(function () { if (nodeLinkFn) nodeLinkFn(vm, el, host) if (childLinkFn) childLinkFn(vm, childNodes, host) }, vm) return makeUnlinkFn(vm, dirs) } } /** * Apply a linker to a vm/element pair and capture the * directives created during the process. * * @param {Function} linker * @param {Vue} vm */ function linkAndCapture (linker, vm) { var originalDirCount = vm._directives.length linker() return vm._directives.slice(originalDirCount) } /** * 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} [context] * @param {Array} [contextDirs] * @return {Function} */ function makeUnlinkFn (vm, dirs, context, contextDirs) { return function unlink (destroying) { teardownDirs(vm, dirs, destroying) if (context && contextDirs) { teardownDirs(context, contextDirs) } } } /** * Teardown partial linked directives. * * @param {Vue} vm * @param {Array} dirs * @param {Boolean} destroying */ function teardownDirs (vm, dirs, destroying) { var i = dirs.length while (i--) { dirs[i]._teardown() if (!destroying) { vm._directives.$remove(dirs[i]) } } } /** * Compile link props on an instance. * * @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 context container (context scope) * 2. attrs on the component template root node, if * replace:true (child scope) * * If this is a fragment instance, we only need to compile 1. * * @param {Vue} vm * @param {Element} el * @param {Object} options * @return {Function} */ exports.compileRoot = function (el, options) { var containerAttrs = options._containerAttrs var replacerAttrs = options._replacerAttrs var contextLinkFn, replacerLinkFn // only need to compile other attributes for // non-fragment instances if (el.nodeType !== 11) { // for components, container and replacer need to be // compiled separately and linked in different scopes. if (options._asComponent) { // 2. container attributes if (containerAttrs) { contextLinkFn = compileDirectives(containerAttrs, options) } if (replacerAttrs) { // 3. replacer attributes replacerLinkFn = compileDirectives(replacerAttrs, options) } } else { // non-component, just compile as a normal element. replacerLinkFn = compileDirectives(el.attributes, options) } } return function rootLinkFn (vm, el) { // link context scope dirs var context = vm._context var contextDirs if (context && contextLinkFn) { contextDirs = linkAndCapture(function () { contextLinkFn(context, el) }, context) } // link self var selfDirs = linkAndCapture(function () { if (replacerLinkFn) replacerLinkFn(vm, el) }, vm) // return the unlink function that tearsdown context // container directives. return makeUnlinkFn(vm, selfDirs, context, contextDirs) } } /** * Compile a node and return a nodeLinkFn based on the * node type. * * @param {Node} node * @param {Object} options * @return {Function|null} */ function compileNode (node, options) { var type = node.nodeType if (type === 1 && node.tagName !== 'SCRIPT') { return compileElement(node, options) } else if (type === 3 && config.interpolate && node.data.trim()) { return compileTextNode(node, options) } else { return null } } /** * Compile an element and return a nodeLinkFn. * * @param {Element} el * @param {Object} options * @return {Function|null} */ function compileElement (el, options) { // preprocess textareas. // textarea treats its text content as the initial value. // just bind it as a v-attr directive for value. if (el.tagName === 'TEXTAREA') { if (textParser.parse(el.value)) { el.setAttribute('value', el.value) } } var linkFn var hasAttrs = el.hasAttributes() // check terminal directives (repeat & if) if (hasAttrs) { linkFn = checkTerminalDirectives(el, options) } // check element directives if (!linkFn) { linkFn = checkElementDirectives(el, options) } // check component if (!linkFn) { linkFn = checkComponent(el, options) } // normal directives if (!linkFn && hasAttrs) { linkFn = compileDirectives(el.attributes, options) } return linkFn } /** * Compile a textNode and return a nodeLinkFn. * * @param {TextNode} node * @param {Object} options * @return {Function|null} textNodeLinkFn */ function compileTextNode (node, options) { var tokens = textParser.parse(node.data) if (!tokens) { return null } var frag = document.createDocumentFragment() var el, token for (var i = 0, l = tokens.length; i < l; i++) { token = tokens[i] el = token.tag ? processTextToken(token, options) : document.createTextNode(token.value) frag.appendChild(el) } return makeTextNodeLinkFn(tokens, frag, options) } /** * Process a single text token. * * @param {Object} token * @param {Object} options * @return {Node} */ function processTextToken (token, options) { var el if (token.oneTime) { el = document.createTextNode(token.value) } else { if (token.html) { el = document.createComment('v-html') setTokenType('html') } else { // IE will clean up empty textNodes during // frag.cloneNode(true), so we have to give it // something here... el = document.createTextNode(' ') setTokenType('text') } } function setTokenType (type) { token.type = type token.def = resolveAsset(options, 'directives', type) token.descriptor = dirParser.parse(token.value)[0] } return el } /** * Build a function that processes a textNode. * * @param {Array} tokens * @param {DocumentFragment} frag */ function makeTextNodeLinkFn (tokens, frag) { return function textNodeLinkFn (vm, el) { var fragClone = frag.cloneNode(true) var childNodes = _.toArray(fragClone.childNodes) var token, value, node for (var i = 0, l = tokens.length; i < l; i++) { token = tokens[i] value = token.value if (token.tag) { node = childNodes[i] if (token.oneTime) { value = vm.$eval(value) if (token.html) { _.replace(node, templateParser.parse(value, true)) } else { node.data = value } } else { vm._bindDir(token.type, node, token.descriptor, token.def) } } } _.replace(el, fragClone) } } /** * Compile a node list and return a childLinkFn. * * @param {NodeList} nodeList * @param {Object} options * @return {Function|undefined} */ function compileNodeList (nodeList, options) { var linkFns = [] var nodeLinkFn, childLinkFn, node for (var i = 0, l = nodeList.length; i < l; i++) { node = nodeList[i] nodeLinkFn = compileNode(node, options) childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && node.tagName !== 'SCRIPT' && node.hasChildNodes() ? compileNodeList(node.childNodes, options) : null linkFns.push(nodeLinkFn, childLinkFn) } return linkFns.length ? makeChildLinkFn(linkFns) : null } /** * Make a child link function for a node's childNodes. * * @param {Array} linkFns * @return {Function} childLinkFn */ function makeChildLinkFn (linkFns) { return function childLinkFn (vm, nodes, host) { var node, nodeLinkFn, childrenLinkFn for (var i = 0, n = 0, l = linkFns.length; i < l; n++) { node = nodes[n] nodeLinkFn = linkFns[i++] childrenLinkFn = linkFns[i++] // cache childNodes before linking parent, fix #657 var childNodes = _.toArray(node.childNodes) if (nodeLinkFn) { nodeLinkFn(vm, node, host) } if (childrenLinkFn) { childrenLinkFn(vm, childNodes, host) } } } } /** * Check for element directives (custom elements that should * be resovled as terminal directives). * * @param {Element} el * @param {Object} options */ function checkElementDirectives (el, options) { var tag = el.tagName.toLowerCase() if (_.commonTagRE.test(tag)) return var def = resolveAsset(options, 'elementDirectives', tag) if (def) { return makeTerminalNodeLinkFn(el, tag, '', options, def) } } /** * Check if an element is a component. If yes, return * a component link function. * * @param {Element} el * @param {Object} options * @param {Boolean} hasAttrs * @return {Function|undefined} */ function checkComponent (el, options, hasAttrs) { var componentId = _.checkComponent(el, options, hasAttrs) if (componentId) { var componentLinkFn = function (vm, el, host) { vm._bindDir('component', el, { expression: componentId }, componentDef, host) } componentLinkFn.terminal = true return componentLinkFn } } /** * Check an element for terminal directives in fixed order. * If it finds one, return a terminal link function. * * @param {Element} el * @param {Object} options * @return {Function} terminalLinkFn */ function checkTerminalDirectives (el, options) { if (_.attr(el, 'pre') !== null) { return skip } var value, dirName for (var i = 0, l = terminalDirectives.length; i < l; i++) { dirName = terminalDirectives[i] if ((value = _.attr(el, dirName)) !== null) { return makeTerminalNodeLinkFn(el, dirName, value, options) } } } function skip () {} skip.terminal = true /** * Build a node link function for a terminal directive. * A terminal link function terminates the current * compilation recursion and handles compilation of the * subtree in the directive. * * @param {Element} el * @param {String} dirName * @param {String} value * @param {Object} options * @param {Object} [def] * @return {Function} terminalLinkFn */ function makeTerminalNodeLinkFn (el, dirName, value, options, def) { var descriptor = dirParser.parse(value)[0] // no need to call resolveAsset since terminal directives // are always internal def = def || options.directives[dirName] var fn = function terminalNodeLinkFn (vm, el, host) { vm._bindDir(dirName, el, descriptor, def, host) } fn.terminal = true return fn } /** * Compile the directives on an element and return a linker. * * @param {Array|NamedNodeMap} attrs * @param {Object} options * @return {Function} */ function compileDirectives (attrs, options) { var i = attrs.length var dirs = [] var attr, name, value, dir, dirName, dirDef while (i--) { attr = attrs[i] name = attr.name value = attr.value if (name.indexOf(config.prefix) === 0) { dirName = name.slice(config.prefix.length) dirDef = resolveAsset(options, 'directives', dirName) if (true) { _.assertAsset(dirDef, 'directive', dirName) } if (dirDef) { dirs.push({ name: dirName, descriptors: dirParser.parse(value), def: dirDef }) } } else if (config.interpolate) { dir = collectAttrDirective(name, value, options) if (dir) { dirs.push(dir) } } } // sort by priority, LOW to HIGH if (dirs.length) { dirs.sort(directiveComparator) return makeNodeLinkFn(dirs) } } /** * Build a link function for all directives on a single node. * * @param {Array} directives * @return {Function} directivesLinkFn */ function makeNodeLinkFn (directives) { return function nodeLinkFn (vm, el, host) { // reverse apply because it's sorted low to high var i = directives.length var dir, j, k while (i--) { dir = directives[i] if (dir._link) { // custom link fn dir._link(vm, el) } else { k = dir.descriptors.length for (j = 0; j < k; j++) { vm._bindDir(dir.name, el, dir.descriptors[j], dir.def, host) } } } } } /** * Check an attribute for potential dynamic bindings, * and return a directive object. * * Special case: class interpolations are translated into * v-class instead v-attr, so that it can work with user * provided v-class bindings. * * @param {String} name * @param {String} value * @param {Object} options * @return {Object} */ function collectAttrDirective (name, value, options) { var tokens = textParser.parse(value) var isClass = name === 'class' if (tokens) { var dirName = isClass ? 'class' : 'attr' var def = options.directives[dirName] var i = tokens.length var allOneTime = true while (i--) { var token = tokens[i] if (token.tag && !token.oneTime) { allOneTime = false } } return { def: def, _link: allOneTime ? function (vm, el) { el.setAttribute(name, vm.$interpolate(value)) } : function (vm, el) { var exp = textParser.tokensToExp(tokens, vm) var desc = isClass ? dirParser.parse(exp)[0] : dirParser.parse(name + ':' + exp)[0] if (isClass) { desc._rawClass = value } vm._bindDir(dirName, el, desc, def) } } } } /** * Directive priority sort comparator * * @param {Object} a * @param {Object} b */ function directiveComparator (a, b) { a = a.def.priority || 0 b = b.def.priority || 0 return a > b ? 1 : -1 } /***/ }, /* 12 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var textParser = __webpack_require__(13) var propDef = __webpack_require__(16) var propBindingModes = __webpack_require__(5)._propBindingModes // regexes var identRE = __webpack_require__(20).identRE var dataAttrRE = /^data-/ var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/ var literalValueRE = /^(true|false)$|^\d.*/ /** * Compile param attributes on a root element and return * a props link function. * * @param {Element|DocumentFragment} el * @param {Array} propOptions * @return {Function} propsLinkFn */ module.exports = function compileProps (el, propOptions) { var props = [] var i = propOptions.length var options, name, attr, value, path, prop, literal, single while (i--) { options = propOptions[i] name = options.name // props could contain dashes, which will be // interpreted as minus calculations by the parser // so we need to camelize the path here path = _.camelize(name.replace(dataAttrRE, '')) if (!identRE.test(path)) { ("development") !== 'production' && _.warn( 'Invalid prop key: "' + name + '". Prop keys ' + 'must be valid identifiers.' ) continue } attr = _.hyphenate(name) value = el.getAttribute(attr) if (value === null) { attr = 'data-' + attr value = el.getAttribute(attr) } // create a prop descriptor prop = { name: name, raw: value, path: path, options: options, mode: propBindingModes.ONE_WAY } if (value !== null) { // important so that this doesn't get compiled // again as a normal attribute binding el.removeAttribute(attr) var tokens = textParser.parse(value) if (tokens) { prop.dynamic = true prop.parentPath = textParser.tokensToExp(tokens) // check prop binding type. single = tokens.length === 1 literal = literalValueRE.test(prop.parentPath) // one time: {{* prop}} if (literal || (single && tokens[0].oneTime)) { prop.mode = propBindingModes.ONE_TIME } else if ( !literal && (single && tokens[0].twoWay) ) { if (settablePathRE.test(prop.parentPath)) { prop.mode = propBindingModes.TWO_WAY } else { ("development") !== 'production' && _.warn( 'Cannot bind two-way prop with non-settable ' + 'parent path: ' + prop.parentPath ) } } if ( ("development") !== 'production' && options.twoWay && prop.mode !== propBindingModes.TWO_WAY ) { _.warn( 'Prop "' + name + '" expects a two-way binding type.' ) } } } else if (options && options.required) { ("development") !== 'production' && _.warn( 'Missing required prop: ' + name ) } props.push(prop) } return makePropsLinkFn(props) } /** * Build a function that applies props to a vm. * * @param {Array} props * @return {Function} propsLinkFn */ function makePropsLinkFn (props) { return function propsLinkFn (vm, el) { // store resolved props info vm._props = {} var i = props.length var prop, path, options, value while (i--) { prop = props[i] path = prop.path vm._props[path] = prop options = prop.options if (prop.raw === null) { // initialize absent prop _.initProp(vm, prop, getDefault(options)) } else if (prop.dynamic) { // dynamic prop if (vm._context) { if (prop.mode === propBindingModes.ONE_TIME) { // one time binding value = vm._context.$get(prop.parentPath) _.initProp(vm, prop, value) } else { // dynamic binding vm._bindDir('prop', el, prop, propDef) } } else { ("development") !== 'production' && _.warn( 'Cannot bind dynamic prop on a root instance' + ' with no parent: ' + prop.name + '="' + prop.raw + '"' ) } } else { // literal, cast it and just set once var raw = prop.raw value = options.type === Boolean && raw === '' ? true // do not cast emptry string. // _.toNumber casts empty string to 0. : raw.trim() ? _.toBoolean(_.toNumber(raw)) : raw _.initProp(vm, prop, value) } } } } /** * Get the default value of a prop. * * @param {Object} options * @return {*} */ function getDefault (options) { // no default, return undefined if (!options.hasOwnProperty('default')) { // absent boolean value defaults to false return options.type === Boolean ? false : undefined } var def = options.default // warn against non-factory defaults for Object & Array if (_.isObject(def)) { ("development") !== 'production' && _.warn( 'Object/Array as default prop values will be shared ' + 'across multiple instances. Use a factory function ' + 'to return the default value instead.' ) } // call factory function for non-Function types return typeof def === 'function' && options.type !== Function ? def() : def } /***/ }, /* 13 */ /***/ function(module, exports, __webpack_require__) { var Cache = __webpack_require__(14) var config = __webpack_require__(5) var dirParser = __webpack_require__(15) var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g var cache, tagRE, htmlRE, firstChar, lastChar /** * Escape a string so it can be used in a RegExp * constructor. * * @param {String} str */ function escapeRegex (str) { return str.replace(regexEscapeRE, '\\$&') } /** * Compile the interpolation tag regex. * * @return {RegExp} */ function compileRegex () { config._delimitersChanged = false var open = config.delimiters[0] var close = config.delimiters[1] firstChar = open.charAt(0) lastChar = close.charAt(close.length - 1) var firstCharRE = escapeRegex(firstChar) var lastCharRE = escapeRegex(lastChar) var openRE = escapeRegex(open) var closeRE = escapeRegex(close) tagRE = new RegExp( firstCharRE + '?' + openRE + '(.+?)' + closeRE + lastCharRE + '?', 'g' ) htmlRE = new RegExp( '^' + firstCharRE + openRE + '.*' + closeRE + lastCharRE + '$' ) // reset cache cache = new Cache(1000) } /** * Parse a template text string into an array of tokens. * * @param {String} text * @return {Array | null} * - {String} type * - {String} value * - {Boolean} [html] * - {Boolean} [oneTime] */ exports.parse = function (text) { if (config._delimitersChanged) { compileRegex() } var hit = cache.get(text) if (hit) { return hit } text = text.replace(/\n/g, '') if (!tagRE.test(text)) { return null } var tokens = [] var lastIndex = tagRE.lastIndex = 0 var match, index, value, first, oneTime, twoWay /* eslint-disable no-cond-assign */ while (match = tagRE.exec(text)) { /* eslint-enable no-cond-assign */ index = match.index // push text token if (index > lastIndex) { tokens.push({ value: text.slice(lastIndex, index) }) } // tag token first = match[1].charCodeAt(0) oneTime = first === 42 // * twoWay = first === 64 // @ value = oneTime || twoWay ? match[1].slice(1) : match[1] tokens.push({ tag: true, value: value.trim(), html: htmlRE.test(match[0]), oneTime: oneTime, twoWay: twoWay }) lastIndex = index + match[0].length } if (lastIndex < text.length) { tokens.push({ value: text.slice(lastIndex) }) } cache.put(text, tokens) return tokens } /** * Format a list of tokens into an expression. * e.g. tokens parsed from 'a {{b}} c' can be serialized * into one single expression as '"a " + b + " c"'. * * @param {Array} tokens * @param {Vue} [vm] * @return {String} */ exports.tokensToExp = function (tokens, vm) { return tokens.length > 1 ? tokens.map(function (token) { return formatToken(token, vm) }).join('+') : formatToken(tokens[0], vm, true) } /** * Format a single token. * * @param {Object} token * @param {Vue} [vm] * @param {Boolean} single * @return {String} */ function formatToken (token, vm, single) { return token.tag ? vm && token.oneTime ? '"' + vm.$eval(token.value) + '"' : inlineFilters(token.value, single) : '"' + token.value + '"' } /** * For an attribute with multiple interpolation tags, * e.g. attr="some-{{thing | filter}}", in order to combine * the whole thing into a single watchable expression, we * have to inline those filters. This function does exactly * that. This is a bit hacky but it avoids heavy changes * to directive parser and watcher mechanism. * * @param {String} exp * @param {Boolean} single * @return {String} */ var filterRE = /[^|]\|[^|]/ function inlineFilters (exp, single) { if (!filterRE.test(exp)) { return single ? exp : '(' + exp + ')' } else { var dir = dirParser.parse(exp)[0] if (!dir.filters) { return '(' + exp + ')' } else { return 'this._applyFilters(' + dir.expression + // value ',null,' + // oldValue (null for read) JSON.stringify(dir.filters) + // filter descriptors ',false)' // write? } } } /***/ }, /* 14 */ /***/ function(module, exports) { /** * A doubly linked list-based Least Recently Used (LRU) * cache. Will keep most recently used items while * discarding least recently used items when its limit is * reached. This is a bare-bone version of * Rasmus Andersson's js-lru: * * https://github.com/rsms/js-lru * * @param {Number} limit * @constructor */ function Cache (limit) { this.size = 0 this.limit = limit this.head = this.tail = undefined this._keymap = Object.create(null) } var p = Cache.prototype /** * Put into the cache associated with . * Returns the entry which was removed to make room for * the new entry. Otherwise undefined is returned. * (i.e. if there was enough room already). * * @param {String} key * @param {*} value * @return {Entry|undefined} */ p.put = function (key, value) { var entry = { key: key, value: value } this._keymap[key] = entry if (this.tail) { this.tail.newer = entry entry.older = this.tail } else { this.head = entry } this.tail = entry if (this.size === this.limit) { return this.shift() } else { this.size++ } } /** * Purge the least recently used (oldest) entry from the * cache. Returns the removed entry or undefined if the * cache was empty. */ p.shift = function () { var entry = this.head if (entry) { this.head = this.head.newer this.head.older = undefined entry.newer = entry.older = undefined this._keymap[entry.key] = undefined } return entry } /** * Get and register recent use of . Returns the value * associated with or undefined if not in cache. * * @param {String} key * @param {Boolean} returnEntry * @return {Entry|*} */ p.get = function (key, returnEntry) { var entry = this._keymap[key] if (entry === undefined) return if (entry === this.tail) { return returnEntry ? entry : entry.value } // HEAD--------------TAIL // <.older .newer> // <--- add direction -- // A B C E if (entry.newer) { if (entry === this.head) { this.head = entry.newer } entry.newer.older = entry.older // C <-- E. } if (entry.older) { entry.older.newer = entry.newer // C. --> E } entry.newer = undefined // D --x entry.older = this.tail // D. --> E if (this.tail) { this.tail.newer = entry // E. <-- D } this.tail = entry return returnEntry ? entry : entry.value } module.exports = Cache /***/ }, /* 15 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var Cache = __webpack_require__(14) var cache = new Cache(1000) var argRE = /^[^\{\?]+$|^'[^']*'$|^"[^"]*"$/ var filterTokenRE = /[^\s'"]+|'[^']*'|"[^"]*"/g var reservedArgRE = /^in$|^-?\d+/ /** * Parser state */ var str var c, i, l var inSingle var inDouble var curly var square var paren var begin var argIndex var dirs var dir var lastFilterIndex var arg /** * Push a directive object into the result Array */ function pushDir () { dir.raw = str.slice(begin, i).trim() if (dir.expression === undefined) { dir.expression = str.slice(argIndex, i).trim() } else if (lastFilterIndex !== begin) { pushFilter() } if (i === 0 || dir.expression) { dirs.push(dir) } } /** * Push a filter to the current directive object */ function pushFilter () { var exp = str.slice(lastFilterIndex, i).trim() var filter if (exp) { filter = {} var tokens = exp.match(filterTokenRE) filter.name = tokens[0] if (tokens.length > 1) { filter.args = tokens.slice(1).map(processFilterArg) } } if (filter) { (dir.filters = dir.filters || []).push(filter) } lastFilterIndex = i + 1 } /** * Check if an argument is dynamic and strip quotes. * * @param {String} arg * @return {Object} */ function processFilterArg (arg) { var stripped = reservedArgRE.test(arg) ? arg : _.stripQuotes(arg) var dynamic = stripped === false return { value: dynamic ? arg : stripped, dynamic: dynamic } } /** * Parse a directive string into an Array of AST-like * objects representing directives. * * Example: * * "click: a = a + 1 | uppercase" will yield: * { * arg: 'click', * expression: 'a = a + 1', * filters: [ * { name: 'uppercase', args: null } * ] * } * * @param {String} str * @return {Array} */ exports.parse = function (s) { var hit = cache.get(s) if (hit) { return hit } // reset parser state str = s inSingle = inDouble = false curly = square = paren = begin = argIndex = 0 lastFilterIndex = 0 dirs = [] dir = {} arg = null for (i = 0, l = str.length; i < l; i++) { c = str.charCodeAt(i) if (inSingle) { // check single quote if (c === 0x27) inSingle = !inSingle } else if (inDouble) { // check double quote if (c === 0x22) inDouble = !inDouble } else if ( c === 0x2C && // comma !paren && !curly && !square ) { // reached the end of a directive pushDir() // reset & skip the comma dir = {} begin = argIndex = lastFilterIndex = i + 1 } else if ( c === 0x3A && // colon !dir.expression && !dir.arg ) { // argument arg = str.slice(begin, i).trim() // test for valid argument here // since we may have caught stuff like first half of // an object literal or a ternary expression. if (argRE.test(arg)) { argIndex = i + 1 dir.arg = _.stripQuotes(arg) || arg } } else if ( c === 0x7C && // pipe str.charCodeAt(i + 1) !== 0x7C && str.charCodeAt(i - 1) !== 0x7C ) { if (dir.expression === undefined) { // first filter, end of expression lastFilterIndex = i + 1 dir.expression = str.slice(argIndex, i).trim() } else { // already has filter pushFilter() } } else { switch (c) { case 0x22: inDouble = true; break // " case 0x27: inSingle = true; break // ' case 0x28: paren++; break // ( case 0x29: paren--; break // ) case 0x5B: square++; break // [ case 0x5D: square--; break // ] case 0x7B: curly++; break // { case 0x7D: curly--; break // } } } } if (i === 0 || begin !== i) { pushDir() } cache.put(s, dirs) return dirs } /***/ }, /* 16 */ /***/ function(module, exports, __webpack_require__) { // 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 _ = __webpack_require__(1) var Watcher = __webpack_require__(17) var bindingModes = __webpack_require__(5)._propBindingModes module.exports = { bind: function () { var child = this.vm var parent = child._context // passed in from compiler directly var prop = this._descriptor var childKey = prop.path var parentKey = prop.parentPath this.parentWatcher = new Watcher( parent, parentKey, function (val) { if (_.assertProp(prop, val)) { child[childKey] = val } }, { sync: true } ) // set the child initial value. var value = this.parentWatcher.value if (childKey === '$data') { child._data = value } else { _.initProp(child, prop, value) } // setup two-way binding if (prop.mode === bindingModes.TWO_WAY) { // 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, function (val) { parent.$set(parentKey, val) }, { sync: true } ) }) } }, unbind: function () { this.parentWatcher.teardown() if (this.childWatcher) { this.childWatcher.teardown() } } } /***/ }, /* 17 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var config = __webpack_require__(5) var Dep = __webpack_require__(18) var expParser = __webpack_require__(19) var batcher = __webpack_require__(21) var uid = 0 /** * A watcher parses an expression, collects dependencies, * and fires callback when the expression value changes. * This is used for both the $watch() api and directives. * * @param {Vue} vm * @param {String} expression * @param {Function} cb * @param {Object} options * - {Array} filters * - {Boolean} twoWay * - {Boolean} deep * - {Boolean} user * - {Boolean} sync * - {Boolean} lazy * - {Function} [preProcess] * @constructor */ function Watcher (vm, expOrFn, cb, options) { // mix in options if (options) { _.extend(this, options) } var isFn = typeof expOrFn === 'function' this.vm = vm vm._watchers.push(this) this.expression = isFn ? expOrFn.toString() : expOrFn this.cb = cb this.id = ++uid // uid for batching this.active = true this.dirty = this.lazy // for lazy watchers this.deps = [] this.newDeps = null this.prevError = null // for async error stacks // parse expression for getter/setter if (isFn) { this.getter = expOrFn this.setter = undefined } else { var res = expParser.parse(expOrFn, this.twoWay) this.getter = res.get this.setter = res.set } this.value = this.lazy ? undefined : this.get() // state for avoiding false triggers for deep and Array // watchers during vm._digest() this.queued = this.shallow = false } /** * Add a dependency to this directive. * * @param {Dep} dep */ Watcher.prototype.addDep = function (dep) { var newDeps = this.newDeps var old = this.deps if (_.indexOf(newDeps, dep) < 0) { newDeps.push(dep) var i = _.indexOf(old, dep) if (i < 0) { dep.addSub(this) } else { old[i] = null } } } /** * Evaluate the getter, and re-collect dependencies. */ Watcher.prototype.get = function () { this.beforeGet() var vm = this.vm var value try { value = this.getter.call(vm, vm) } catch (e) { if ( ("development") !== 'production' && config.warnExpressionErrors ) { _.warn( 'Error when evaluating expression "' + this.expression + '". ' + (config.debug ? '' : 'Turn on debug mode to see stack trace.' ), e ) } } // "touch" every property so they are all tracked as // dependencies for deep watching if (this.deep) { traverse(value) } if (this.preProcess) { value = this.preProcess(value) } if (this.filters) { value = vm._applyFilters(value, null, this.filters, false) } this.afterGet() return value } /** * Set the corresponding value with the setter. * * @param {*} value */ Watcher.prototype.set = function (value) { var vm = this.vm if (this.filters) { value = vm._applyFilters( value, this.value, this.filters, true) } try { this.setter.call(vm, vm, value) } catch (e) { if ( ("development") !== 'production' && config.warnExpressionErrors ) { _.warn( 'Error when evaluating setter "' + this.expression + '"', e ) } } } /** * Prepare for dependency collection. */ Watcher.prototype.beforeGet = function () { Dep.target = this this.newDeps = [] } /** * Clean up for dependency collection. */ Watcher.prototype.afterGet = function () { Dep.target = null var i = this.deps.length while (i--) { var dep = this.deps[i] if (dep) { dep.removeSub(this) } } this.deps = this.newDeps this.newDeps = null } /** * Subscriber interface. * Will be called when a dependency changes. * * @param {Boolean} shallow */ Watcher.prototype.update = function (shallow) { if (this.lazy) { this.dirty = true } else if (this.sync || !config.async) { this.run() } else { // if queued, only overwrite shallow with non-shallow, // but not the other way around. this.shallow = this.queued ? shallow ? this.shallow : false : !!shallow this.queued = true // record before-push error stack in debug mode /* istanbul ignore if */ if (("development") !== 'production' && config.debug) { this.prevError = new Error('[vue] async stack trace') } batcher.push(this) } } /** * Batcher job interface. * Will be called by the batcher. */ Watcher.prototype.run = function () { if (this.active) { var value = this.get() if ( value !== this.value || // Deep watchers and Array watchers should fire even // when the value is the same, because the value may // have mutated; but only do so if this is a // non-shallow update (caused by a vm digest). ((_.isArray(value) || this.deep) && !this.shallow) ) { // set new value var oldValue = this.value this.value = value // in debug + async mode, when a watcher callbacks // throws, we also throw the saved before-push error // so the full cross-tick stack trace is available. var prevError = this.prevError /* istanbul ignore if */ if (("development") !== 'production' && config.debug && prevError) { this.prevError = null try { this.cb.call(this.vm, value, oldValue) } catch (e) { _.nextTick(function () { throw prevError }, 0) throw e } } else { this.cb.call(this.vm, value, oldValue) } } this.queued = this.shallow = false } } /** * Evaluate the value of the watcher. * This only gets called for lazy watchers. */ Watcher.prototype.evaluate = function () { // avoid overwriting another watcher that is being // collected. var current = Dep.target this.value = this.get() this.dirty = false Dep.target = current } /** * Depend on all deps collected by this watcher. */ Watcher.prototype.depend = function () { var i = this.deps.length while (i--) { this.deps[i].depend() } } /** * Remove self from all dependencies' subcriber list. */ Watcher.prototype.teardown = function () { if (this.active) { // remove self from vm's watcher list // we can skip this if the vm if being destroyed // which can improve teardown performance. if (!this.vm._isBeingDestroyed) { this.vm._watchers.$remove(this) } var i = this.deps.length while (i--) { this.deps[i].removeSub(this) } this.active = false this.vm = this.cb = this.value = null } } /** * Recrusively traverse an object to evoke all converted * getters, so that every nested property inside the object * is collected as a "deep" dependency. * * @param {Object} obj */ function traverse (obj) { var key, val, i for (key in obj) { val = obj[key] if (_.isArray(val)) { i = val.length while (i--) traverse(val[i]) } else if (_.isObject(val)) { traverse(val) } } } module.exports = Watcher /***/ }, /* 18 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) /** * A dep is an observable that can have multiple * directives subscribing to it. * * @constructor */ function Dep () { this.subs = [] } // the current target watcher being evaluated. // this is globally unique because there could be only one // watcher being evaluated at any time. Dep.target = null /** * Add a directive subscriber. * * @param {Directive} sub */ Dep.prototype.addSub = function (sub) { this.subs.push(sub) } /** * Remove a directive subscriber. * * @param {Directive} sub */ Dep.prototype.removeSub = function (sub) { this.subs.$remove(sub) } /** * Add self as a dependency to the target watcher. */ Dep.prototype.depend = function () { Dep.target.addDep(this) } /** * Notify all subscribers of a new value. */ Dep.prototype.notify = function () { // stablize the subscriber list first var subs = _.toArray(this.subs) for (var i = 0, l = subs.length; i < l; i++) { subs[i].update() } } module.exports = Dep /***/ }, /* 19 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var Path = __webpack_require__(20) var Cache = __webpack_require__(14) var expressionCache = new Cache(1000) var allowedKeywords = 'Math,Date,this,true,false,null,undefined,Infinity,NaN,' + 'isNaN,isFinite,decodeURI,decodeURIComponent,encodeURI,' + 'encodeURIComponent,parseInt,parseFloat' var allowedKeywordsRE = new RegExp('^(' + allowedKeywords.replace(/,/g, '\\b|') + '\\b)') // keywords that don't make sense inside expressions var improperKeywords = 'break,case,class,catch,const,continue,debugger,default,' + 'delete,do,else,export,extends,finally,for,function,if,' + 'import,in,instanceof,let,return,super,switch,throw,try,' + 'var,while,with,yield,enum,await,implements,package,' + 'proctected,static,interface,private,public' var improperKeywordsRE = new RegExp('^(' + improperKeywords.replace(/,/g, '\\b|') + '\\b)') var wsRE = /\s/g var newlineRE = /\n/g var saveRE = /[\{,]\s*[\w\$_]+\s*:|('[^']*'|"[^"]*")|new |typeof |void /g var restoreRE = /"(\d+)"/g var pathTestRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/ var pathReplaceRE = /[^\w$\.]([A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\])*)/g var booleanLiteralRE = /^(true|false)$/ /** * Save / Rewrite / Restore * * When rewriting paths found in an expression, it is * possible for the same letter sequences to be found in * strings and Object literal property keys. Therefore we * remove and store these parts in a temporary array, and * restore them after the path rewrite. */ var saved = [] /** * Save replacer * * The save regex can match two possible cases: * 1. An opening object literal * 2. A string * If matched as a plain string, we need to escape its * newlines, since the string needs to be preserved when * generating the function body. * * @param {String} str * @param {String} isString - str if matched as a string * @return {String} - placeholder with index */ function save (str, isString) { var i = saved.length saved[i] = isString ? str.replace(newlineRE, '\\n') : str return '"' + i + '"' } /** * Path rewrite replacer * * @param {String} raw * @return {String} */ function rewrite (raw) { var c = raw.charAt(0) var path = raw.slice(1) if (allowedKeywordsRE.test(path)) { return raw } else { path = path.indexOf('"') > -1 ? path.replace(restoreRE, restore) : path return c + 'scope.' + path } } /** * Restore replacer * * @param {String} str * @param {String} i - matched save index * @return {String} */ function restore (str, i) { return saved[i] } /** * Rewrite an expression, prefixing all path accessors with * `scope.` and generate getter/setter functions. * * @param {String} exp * @param {Boolean} needSet * @return {Function} */ function compileExpFns (exp, needSet) { if (improperKeywordsRE.test(exp)) { ("development") !== 'production' && _.warn( 'Avoid using reserved keywords in expression: ' + exp ) } // reset state saved.length = 0 // save strings and object literal keys var body = exp .replace(saveRE, save) .replace(wsRE, '') // rewrite all paths // pad 1 space here becaue the regex matches 1 extra char body = (' ' + body) .replace(pathReplaceRE, rewrite) .replace(restoreRE, restore) var getter = makeGetter(body) if (getter) { return { get: getter, body: body, set: needSet ? makeSetter(body) : null } } } /** * Compile getter setters for a simple path. * * @param {String} exp * @return {Function} */ function compilePathFns (exp) { var getter, path if (exp.indexOf('[') < 0) { // really simple path path = exp.split('.') path.raw = exp getter = Path.compileGetter(path) } else { // do the real parsing path = Path.parse(exp) getter = path.get } return { get: getter, // always generate setter for simple paths set: function (obj, val) { Path.set(obj, path, val) } } } /** * Build a getter function. Requires eval. * * We isolate the try/catch so it doesn't affect the * optimization of the parse function when it is not called. * * @param {String} body * @return {Function|undefined} */ function makeGetter (body) { try { return new Function('scope', 'return ' + body + ';') } catch (e) { ("development") !== 'production' && _.warn( 'Invalid expression. ' + 'Generated function body: ' + body ) } } /** * Build a setter function. * * This is only needed in rare situations like "a[b]" where * a settable path requires dynamic evaluation. * * This setter function may throw error when called if the * expression body is not a valid left-hand expression in * assignment. * * @param {String} body * @return {Function|undefined} */ function makeSetter (body) { try { return new Function('scope', 'value', body + '=value;') } catch (e) { ("development") !== 'production' && _.warn( 'Invalid setter function body: ' + body ) } } /** * Check for setter existence on a cache hit. * * @param {Function} hit */ function checkSetter (hit) { if (!hit.set) { hit.set = makeSetter(hit.body) } } /** * Parse an expression into re-written getter/setters. * * @param {String} exp * @param {Boolean} needSet * @return {Function} */ exports.parse = function (exp, needSet) { exp = exp.trim() // try cache var hit = expressionCache.get(exp) if (hit) { if (needSet) { checkSetter(hit) } return hit } // we do a simple path check to optimize for them. // the check fails valid paths with unusal whitespaces, // but that's too rare and we don't care. // also skip boolean literals and paths that start with // global "Math" var res = exports.isSimplePath(exp) ? compilePathFns(exp) : compileExpFns(exp, needSet) expressionCache.put(exp, res) return res } /** * Check if an expression is a simple path. * * @param {String} exp * @return {Boolean} */ exports.isSimplePath = function (exp) { return pathTestRE.test(exp) && // don't treat true/false as paths !booleanLiteralRE.test(exp) && // Math constants e.g. Math.PI, Math.E etc. exp.slice(0, 5) !== 'Math.' } /***/ }, /* 20 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var Cache = __webpack_require__(14) var pathCache = new Cache(1000) var identRE = exports.identRE = /^[$_a-zA-Z]+[\w$]*$/ // actions var APPEND = 0 var PUSH = 1 // states var BEFORE_PATH = 0 var IN_PATH = 1 var BEFORE_IDENT = 2 var IN_IDENT = 3 var BEFORE_ELEMENT = 4 var AFTER_ZERO = 5 var IN_INDEX = 6 var IN_SINGLE_QUOTE = 7 var IN_DOUBLE_QUOTE = 8 var IN_SUB_PATH = 9 var AFTER_ELEMENT = 10 var AFTER_PATH = 11 var ERROR = 12 var pathStateMachine = [] pathStateMachine[BEFORE_PATH] = { 'ws': [BEFORE_PATH], 'ident': [IN_IDENT, APPEND], '[': [BEFORE_ELEMENT], 'eof': [AFTER_PATH] } pathStateMachine[IN_PATH] = { 'ws': [IN_PATH], '.': [BEFORE_IDENT], '[': [BEFORE_ELEMENT], 'eof': [AFTER_PATH] } pathStateMachine[BEFORE_IDENT] = { 'ws': [BEFORE_IDENT], 'ident': [IN_IDENT, APPEND] } pathStateMachine[IN_IDENT] = { 'ident': [IN_IDENT, APPEND], '0': [IN_IDENT, APPEND], 'number': [IN_IDENT, APPEND], 'ws': [IN_PATH, PUSH], '.': [BEFORE_IDENT, PUSH], '[': [BEFORE_ELEMENT, PUSH], 'eof': [AFTER_PATH, PUSH] } pathStateMachine[BEFORE_ELEMENT] = { 'ws': [BEFORE_ELEMENT], '0': [AFTER_ZERO, APPEND], 'number': [IN_INDEX, APPEND], "'": [IN_SINGLE_QUOTE, APPEND, ''], '"': [IN_DOUBLE_QUOTE, APPEND, ''], 'ident': [IN_SUB_PATH, APPEND, '*'] } pathStateMachine[AFTER_ZERO] = { 'ws': [AFTER_ELEMENT, PUSH], ']': [IN_PATH, PUSH] } pathStateMachine[IN_INDEX] = { '0': [IN_INDEX, APPEND], 'number': [IN_INDEX, APPEND], 'ws': [AFTER_ELEMENT], ']': [IN_PATH, PUSH] } pathStateMachine[IN_SINGLE_QUOTE] = { "'": [AFTER_ELEMENT], 'eof': ERROR, 'else': [IN_SINGLE_QUOTE, APPEND] } pathStateMachine[IN_DOUBLE_QUOTE] = { '"': [AFTER_ELEMENT], 'eof': ERROR, 'else': [IN_DOUBLE_QUOTE, APPEND] } pathStateMachine[IN_SUB_PATH] = { 'ident': [IN_SUB_PATH, APPEND], '0': [IN_SUB_PATH, APPEND], 'number': [IN_SUB_PATH, APPEND], 'ws': [AFTER_ELEMENT], ']': [IN_PATH, PUSH] } pathStateMachine[AFTER_ELEMENT] = { 'ws': [AFTER_ELEMENT], ']': [IN_PATH, PUSH] } /** * Determine the type of a character in a keypath. * * @param {Char} ch * @return {String} type */ function getPathCharType (ch) { if (ch === undefined) { return 'eof' } var code = ch.charCodeAt(0) switch (code) { case 0x5B: // [ case 0x5D: // ] case 0x2E: // . case 0x22: // " case 0x27: // ' case 0x30: // 0 return ch case 0x5F: // _ case 0x24: // $ return 'ident' case 0x20: // Space case 0x09: // Tab case 0x0A: // Newline case 0x0D: // Return case 0xA0: // No-break space case 0xFEFF: // Byte Order Mark case 0x2028: // Line Separator case 0x2029: // Paragraph Separator return 'ws' } // a-z, A-Z if ( (code >= 0x61 && code <= 0x7A) || (code >= 0x41 && code <= 0x5A) ) { return 'ident' } // 1-9 if (code >= 0x31 && code <= 0x39) { return 'number' } return 'else' } /** * Parse a string path into an array of segments * Todo implement cache * * @param {String} path * @return {Array|undefined} */ function parsePath (path) { var keys = [] var index = -1 var mode = BEFORE_PATH var c, newChar, key, type, transition, action, typeMap var actions = [] actions[PUSH] = function () { if (key === undefined) { return } keys.push(key) key = undefined } actions[APPEND] = function () { if (key === undefined) { key = newChar } else { key += newChar } } function maybeUnescapeQuote () { var nextChar = path[index + 1] if ((mode === IN_SINGLE_QUOTE && nextChar === "'") || (mode === IN_DOUBLE_QUOTE && nextChar === '"')) { index++ newChar = nextChar actions[APPEND]() return true } } while (mode != null) { index++ c = path[index] if (c === '\\' && maybeUnescapeQuote()) { continue } type = getPathCharType(c) typeMap = pathStateMachine[mode] transition = typeMap[type] || typeMap['else'] || ERROR if (transition === ERROR) { return // parse error } mode = transition[0] action = actions[transition[1]] if (action) { newChar = transition[2] newChar = newChar === undefined ? c : newChar === '*' ? newChar + c : newChar action() } if (mode === AFTER_PATH) { keys.raw = path return keys } } } /** * Format a accessor segment based on its type. * * @param {String} key * @return {Boolean} */ function formatAccessor (key) { if (identRE.test(key)) { // identifier return '.' + key } else if (+key === key >>> 0) { // bracket index return '[' + key + ']' } else if (key.charAt(0) === '*') { return '[o' + formatAccessor(key.slice(1)) + ']' } else { // bracket string return '["' + key.replace(/"/g, '\\"') + '"]' } } /** * Compiles a getter function with a fixed path. * The fixed path getter supresses errors. * * @param {Array} path * @return {Function} */ exports.compileGetter = function (path) { var body = 'return o' + path.map(formatAccessor).join('') return new Function('o', body) } /** * External parse that check for a cache hit first * * @param {String} path * @return {Array|undefined} */ exports.parse = function (path) { var hit = pathCache.get(path) if (!hit) { hit = parsePath(path) if (hit) { hit.get = exports.compileGetter(hit) pathCache.put(path, hit) } } return hit } /** * Get from an object from a path string * * @param {Object} obj * @param {String} path */ exports.get = function (obj, path) { path = exports.parse(path) if (path) { return path.get(obj) } } /** * Set on an object from a path * * @param {Object} obj * @param {String | Array} path * @param {*} val */ exports.set = function (obj, path, val) { var original = obj if (typeof path === 'string') { path = exports.parse(path) } if (!path || !_.isObject(obj)) { return false } var last, key for (var i = 0, l = path.length; i < l; i++) { last = obj key = path[i] if (key.charAt(0) === '*') { key = original[key.slice(1)] } if (i < l - 1) { obj = obj[key] if (!_.isObject(obj)) { warnNonExistent(path) obj = {} last.$add(key, obj) } } else { if (_.isArray(obj)) { obj.$set(key, val) } else if (key in obj) { obj[key] = val } else { warnNonExistent(path) obj.$add(key, val) } } } return true } function warnNonExistent (path) { ("development") !== 'production' && _.warn( 'You are setting a non-existent path "' + path.raw + '" ' + 'on a vm instance. Consider pre-initializing the property ' + 'with the "data" option for more reliable reactivity ' + 'and better performance.' ) } /***/ }, /* 21 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var config = __webpack_require__(5) // we have two separate queues: one for directive updates // and one for user watcher registered via $watch(). // we want to guarantee directive updates to be called // before user watchers so that when user watchers are // triggered, the DOM would have already been in updated // state. var queue = [] var userQueue = [] var has = {} var circular = {} var waiting = false var internalQueueDepleted = false /** * Reset the batcher's state. */ function resetBatcherState () { queue = [] userQueue = [] has = {} circular = {} waiting = internalQueueDepleted = false } /** * Flush both queues and run the watchers. */ function flushBatcherQueue () { runBatcherQueue(queue) internalQueueDepleted = true runBatcherQueue(userQueue) resetBatcherState() } /** * Run the watchers in a single queue. * * @param {Array} queue */ function runBatcherQueue (queue) { // do not cache length because more watchers might be pushed // as we run existing watchers for (var i = 0; i < queue.length; i++) { var watcher = queue[i] var id = watcher.id has[id] = null watcher.run() // in dev build, check and stop circular updates. if (("development") !== '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 ) } } } } /** * 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 {Watcher} watcher * properties: * - {Number} id * - {Function} 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 } // push watcher into appropriate queue var q = watcher.user ? userQueue : queue has[id] = q.length q.push(watcher) // queue the flush if (!waiting) { waiting = true _.nextTick(flushBatcherQueue) } } } /***/ }, /* 22 */ /***/ function(module, exports, __webpack_require__) { var _ = __webpack_require__(1) var Cache = __webpack_require__(14) var templateCache = new Cache(1000) var idSelectorCache = new Cache(1000) var map = { _default: [0, '', ''], legend: [1, '
', '
'], tr: [2, '', '
'], col: [ 2, '', '
' ] } map.td = map.th = [ 3, '', '
' ] map.option = map.optgroup = [ 1, '' ] map.thead = map.tbody = map.colgroup = map.caption = map.tfoot = [1, '', '
'] map.g = map.defs = map.symbol = map.use = map.image = map.text = map.circle = map.ellipse = map.line = map.path = map.polygon = map.polyline = map.rect = [ 1, '', '' ] /** * Check if a node is a supported template node with a * DocumentFragment content. * * @param {Node} node * @return {Boolean} */ function isRealTemplate (node) { return _.isTemplate(node) && node.content instanceof DocumentFragment } var tagRE = /<([\w:]+)/ var entityRE = /&\w+;/ /** * Convert a string template to a DocumentFragment. * Determines correct wrapping by tag types. Wrapping * strategy found in jQuery & component/domify. * * @param {String} templateString * @return {DocumentFragment} */ function stringToFragment (templateString) { // try a cache hit first var hit = templateCache.get(templateString) if (hit) { return hit } var frag = document.createDocumentFragment() var tagMatch = templateString.match(tagRE) var entityMatch = entityRE.test(templateString) if (!tagMatch && !entityMatch) { // text only, return a single text node. frag.appendChild( document.createTextNode(templateString) ) } else { var tag = tagMatch && tagMatch[1] var wrap = map[tag] || map._default var depth = wrap[0] var prefix = wrap[1] var suffix = wrap[2] var node = document.createElement('div') node.innerHTML = prefix + templateString.trim() + suffix while (depth--) { node = node.lastChild } var child /* eslint-disable no-cond-assign */ while (child = node.firstChild) { /* eslint-enable no-cond-assign */ frag.appendChild(child) } } templateCache.put(templateString, frag) return frag } /** * Convert a template node to a DocumentFragment. * * @param {Node} node * @return {DocumentFragment} */ function nodeToFragment (node) { // if its a template tag and the browser supports it, // its content is already a document fragment. if (isRealTemplate(node)) { _.trimNode(node.content) return node.content } // script template if (node.tagName === 'SCRIPT') { return stringToFragment(node.textContent) } // normal node, clone it to avoid mutating the original var clone = exports.clone(node) var frag = document.createDocumentFragment() var child /* eslint-disable no-cond-assign */ while (child = clone.firstChild) { /* eslint-enable no-cond-assign */ frag.appendChild(child) } _.trimNode(frag) return frag } // Test for the presence of the Safari template cloning bug // https://bugs.webkit.org/show_bug.cgi?id=137755 var hasBrokenTemplate = _.inBrowser ? (function () { var a = document.createElement('div') a.innerHTML = '' return !a.cloneNode(true).firstChild.innerHTML })() : false // Test for IE10/11 textarea placeholder clone bug var hasTextareaCloneBug = _.inBrowser ? (function () { var t = document.createElement('textarea') t.placeholder = 't' return t.cloneNode(true).value === 't' })() : false /** * 1. Deal with Safari cloning nested