diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..231a94b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2016 Evan You + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 55cdca8..c7343c9 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ +> **NOTE**: this demo is using Vue.js 1.x - the 2.0 version is [here](https://github.com/vuejs/vue-hackernews-2.0). + # Vue.js HackerNews clone [Live demo](http://vuejs.github.io/vue-hackernews/) -Built with [Vue.js](http://vuejs.org) and the official [HackerNews API](https://github.com/HackerNews/API), with routing, comments, comment folding, user profile & realtime updates. +Built with [Vue.js](http://vuejs.org), [vue-router](https://github.com/vuejs/vue-router) and the official [HackerNews API](https://github.com/HackerNews/API), with routing, comments, comment folding, user profile & realtime updates. -The build setup uses Webpack and the [vue-loader](https://github.com/vuejs/vue-loader) plugin, which enables Vue components to be written in a format that encapsulates a component's style, template and logic in a single file. +The build setup uses [Webpack](http://webpack.github.io/) and the [vue-loader](https://github.com/vuejs/vue-loader) plugin, which enables Vue components to be written in a format that encapsulates a component's style, template and logic in a single file. If you are using SublimeText you can get proper syntax highlighting for `*.vue` files with [vue-syntax-highlight](https://github.com/vuejs/vue-syntax-highlight). -There's also a version of this app built with Browserify + [Vueify](https://github.com/vuejs/vueify) in the [browserify branch](https://github.com/vuejs/vue-hackernews/tree/browserify), although it is recommended to use the Webpack-based setup because of better dependency tracking enabled via Webpack loaders. - ### Building ``` bash @@ -19,3 +19,7 @@ npm run dev # build: npm run build ``` + +### License + +[MIT](http://opensource.org/licenses/MIT) diff --git a/build/build.js b/build/build.js deleted file mode 100644 index 86a5c41..0000000 --- a/build/build.js +++ /dev/null @@ -1,11429 +0,0 @@ -/******/ (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__) { - - /** - * Boot up the Vue instance and wire up the router. - */ - - var Vue = __webpack_require__(1) - var Router = __webpack_require__(70).Router - var app = new Vue(__webpack_require__(71)) - var router = new Router() - - router.on('/news/:page', function (page) { - app.view = 'news-view' - app.params.page = +page - }) - - router.on('/user/:id', function (id) { - window.scrollTo(0, 0) - app.view = 'user-view' - app.params.userId = id - }) - - router.on('/item/:id', function (id) { - window.scrollTo(0, 0) - app.view = 'item-view' - app.params.itemId = id - }) - - router.configure({ - notfound: function () { - router.setRoute('/news/1') - } - }) - - router.init('/news/1') - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - 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__(10)) - - /** - * 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 = { - directives: __webpack_require__(34), - filters: __webpack_require__(56), - transitions: {}, - components: {}, - elementDirectives: { - content: __webpack_require__(58) - } - } - - /** - * 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__(59)) - extend(p, __webpack_require__(60)) - extend(p, __webpack_require__(61)) - extend(p, __webpack_require__(62)) - extend(p, __webpack_require__(64)) - - /** - * Mixin public API methods - */ - - extend(p, __webpack_require__(65)) - extend(p, __webpack_require__(66)) - extend(p, __webpack_require__(67)) - extend(p, __webpack_require__(68)) - extend(p, __webpack_require__(69)) - - module.exports = _.Vue = Vue - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - var lang = __webpack_require__(5) - var extend = lang.extend - - extend(exports, lang) - extend(exports, __webpack_require__(6)) - extend(exports, __webpack_require__(7)) - extend(exports, __webpack_require__(3)) - extend(exports, __webpack_require__(8)) - extend(exports, __webpack_require__(9)) - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - var config = __webpack_require__(4) - var commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/ - var tableElementsRE = /^caption|colgroup|thead|tfoot|tbody|tr|td|th$/ - - /** - * Check if an element is a component, if yes return its - * component id. - * - * @param {Element} el - * @param {Object} options - * @return {String|undefined} - */ - - 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 ( - !commonTagRE.test(tag) && - _.resolveAsset(options, 'components', tag) - ) { - return tag - } else if ( - tableElementsRE.test(tag) && - (tag = _.attr(el, 'component')) - ) { - return tag - } - } - - /** - * Create an "anchor" for performing dom insertion/removals. - * This is used in a number of scenarios: - * - block 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 ? ' ' : '') - } - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 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, - - /** - * 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: [ - 'directive', - 'elementDirective', - 'filter', - 'transition' - ] - - } - - /** - * 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 - } - }) - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * 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 numbers before - * setting back to data - * - * @param {*} value - * @return {*|Number} - */ - - exports.toNumber = function (value) { - return ( - isNaN(value) || - value === null || - typeof value === 'boolean' - ) ? value - : Number(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 - } - - /** - * Replace helper - * - * @param {String} _ - matched delimiter - * @param {String} c - matched char - * @return {String} - */ - function toUpper (_, c) { - return c ? c.toUpperCase () : '' - } - - /** - * Camelize a hyphen-delmited string. - * - * @param {String} str - * @return {String} - */ - - var camelRE = /-(\w)/g - exports.camelize = function (str) { - return str.replace(camelRE, toUpper) - } - - /** - * 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 && 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 = function (obj) { - return Array.isArray(obj) - } - - /** - * 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 - } - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - // 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 handle () { - 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(handle) - 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(handle, 0) - } - })() - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - - var config = __webpack_require__(4) - - /** - * 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()) { - rawContent = asFragment - ? document.createDocumentFragment() - : document.createElement('div') - /* jshint boss:true */ - while (child = el.firstChild) { - rawContent.appendChild(child) - } - } - return rawContent - } - - /** - * 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' - } - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - var config = __webpack_require__(4) - - /** - * Enable debug utilities. The enableDebug() function and - * all _.log() & _.warn() calls will be dropped in the - * minified production build. - */ - - enableDebug() - - function enableDebug () { - - 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) { - /* jshint debug: true */ - 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 === 'component') { - exports.warn( - 'v-component can only be used on table elements ' + - 'in ^0.12.0. Use custom element syntax instead.' - ) - return - } - if (id === 'with') { - 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__(2) - 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') { - _.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 { - // instance merge, return raw object - var instanceData = typeof childVal === 'function' - ? childVal.call(vm) - : childVal - var defaultData = typeof parentVal === 'function' - ? parentVal.call(vm) - : undefined - if (instanceData) { - return mergeData(instanceData, defaultData) - } else { - return defaultData - } - } - } - - /** - * El - */ - - strats.el = function (parentVal, childVal, vm) { - if (!vm && childVal && typeof childVal !== 'function') { - _.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 */ - _.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. - */ - - strats.directives = - strats.filters = - strats.transitions = - strats.components = - strats.elementDirectives = function (parentVal, childVal) { - var res = Object.create(parentVal) - return childVal - ? extend(res, childVal) - : res - } - - /** - * 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} components - */ - - function guardComponents (components) { - if (components) { - var def - for (var key in components) { - def = components[key] - if (_.isPlainObject(def)) { - def.name = key - components[key] = _.Vue.extend(def) - } - } - } - } - - /** - * 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.components) - 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 asset = options[type][id] - while (!asset && options._parent) { - options = options._parent.$options - asset = options[type][id] - } - return asset - } - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - var config = __webpack_require__(4) - - /** - * Expose useful internals - */ - - exports.util = _ - exports.nextTick = _.nextTick - exports.config = __webpack_require__(4) - exports.compiler = __webpack_require__(11) - - exports.parsers = { - path: __webpack_require__(30), - text: __webpack_require__(15), - template: __webpack_require__(13), - directive: __webpack_require__(19), - expression: __webpack_require__(29) - } - - /** - * 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 inehritance - * - * @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. - createAssetRegisters(Sub) - 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 - } - - /** - * Define asset registration methods on a constructor. - * - * @param {Function} Constructor - */ - - function createAssetRegisters (Constructor) { - - /* Asset registration methods share the same signature: - * - * @param {String} id - * @param {*} definition - */ - - config._assetTypes.forEach(function (type) { - Constructor[type] = function (id, definition) { - if (!definition) { - return this.options[type + 's'][id] - } else { - this.options[type + 's'][id] = definition - } - } - }) - - /** - * Component registration needs to automatically invoke - * Vue.extend on object values. - * - * @param {String} id - * @param {Object|Function} definition - */ - - Constructor.component = function (id, definition) { - if (!definition) { - return this.options.components[id] - } else { - if (_.isPlainObject(definition)) { - definition.name = id - definition = _.Vue.extend(definition) - } - this.options.components[id] = definition - } - } - } - - createAssetRegisters(exports) - - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - - _.extend(exports, __webpack_require__(12)) - _.extend(exports, __webpack_require__(33)) - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - var config = __webpack_require__(4) - var textParser = __webpack_require__(15) - var dirParser = __webpack_require__(19) - var templateParser = __webpack_require__(13) - var resolveAsset = _.resolveAsset - - // internal directives - var propDef = __webpack_require__(23) - var componentDef = __webpack_require__(32) - - // 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 - * @param {Vue} [host] - host vm of transcluded content - * @return {Function} - */ - - exports.compile = function (el, options, partial, host) { - // 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 - * @return {Function|undefined} - */ - - return function compositeLinkFn (vm, el) { - // 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) - - /** - * The linker function returns an unlink function that - * tearsdown all directives instances generated during - * the process. - * - * @param {Boolean} destroying - */ - return function unlink (destroying) { - teardownDirs(vm, dirs, destroying) - } - } - } - - /** - * 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) - } - - /** - * Teardown partial linked directives. - * - * @param {Vue} vm - * @param {Array} dirs - * @param {Boolean} destroying - */ - - function teardownDirs (vm, dirs, destroying) { - if (!dirs) return - var i = dirs.length - while (i--) { - dirs[i]._teardown() - if (!destroying) { - vm._directives.$remove(dirs[i]) - } - } - } - - /** - * Compile the root element of an instance. There are - * 3 types of things to process here: - * - * 1. props on parent container (child scope) - * 2. other attrs on parent container (parent scope) - * 3. attrs on the component template root node, if - * replace:true (child scope) - * - * Also, if this is a block instance, we only need to - * compile 1 & 2 here. - * - * This function does compile and link at the same time, - * since root linkers can not be reused. It returns the - * unlink function for potential parent directives on the - * container. - * - * @param {Vue} vm - * @param {Element} el - * @param {Object} options - * @return {Function} - */ - - exports.compileAndLinkRoot = function (vm, el, options) { - var containerAttrs = options._containerAttrs - var replacerAttrs = options._replacerAttrs - var props = options.props - var propsLinkFn, parentLinkFn, replacerLinkFn - - // 1. props - propsLinkFn = props && containerAttrs - ? compileProps(el, containerAttrs, props) - : null - - // only need to compile other attributes for - // non-block 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) { - parentLinkFn = compileDirectives(containerAttrs, options) - } - if (replacerAttrs) { - // 3. replacer attributes - replacerLinkFn = compileDirectives(replacerAttrs, options) - } - } else { - // non-component, just compile as a normal element. - replacerLinkFn = compileDirectives(el, options) - } - } - - // link parent dirs - var parent = vm.$parent - var parentDirs - if (parent && parentLinkFn) { - parentDirs = linkAndCapture(function () { - parentLinkFn(parent, el) - }, parent) - } - - // link self - var selfDirs = linkAndCapture(function () { - if (propsLinkFn) propsLinkFn(vm, null) - if (replacerLinkFn) replacerLinkFn(vm, el) - }, vm) - - // return the unlink function that tearsdown parent - // container directives. - return function rootUnlinkFn () { - teardownDirs(parent, parentDirs) - teardownDirs(vm, selfDirs) - } - } - - /** - * 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) { - var hasAttrs = el.hasAttributes() - // check element directives - var linkFn = checkElementDirectives(el, options) - // check terminal directives (repeat & if) - if (!linkFn && hasAttrs) { - linkFn = checkTerminalDirectives(el, options) - } - // check component - if (!linkFn) { - linkFn = checkComponent(el, options) - } - // normal directives - if (!linkFn && hasAttrs) { - linkFn = compileDirectives(el, options) - } - // if the element is a textarea, we need to interpolate - // its content on initial render. - if (el.tagName === 'TEXTAREA') { - var realLinkFn = linkFn - linkFn = function (vm, el) { - el.value = vm.$interpolate(el.value) - if (realLinkFn) realLinkFn(vm, el) - } - linkFn.terminal = true - } - 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) - } - } - } - } - - /** - * Compile param attributes on a root element and return - * a props link function. - * - * @param {Element|DocumentFragment} el - * @param {Object} attrs - * @param {Array} propNames - * @return {Function} propsLinkFn - */ - - var dataAttrRE = /^data-/ - var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/ - var literalValueRE = /^(true|false|\d+)$/ - var identRE = __webpack_require__(30).identRE - - function compileProps (el, attrs, propNames) { - var props = [] - var i = propNames.length - var name, value, path, prop, settable, literal, single - while (i--) { - name = propNames[i] - // 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 (/[A-Z]/.test(name)) { - _.warn( - 'You seem to be using camelCase for a component prop, ' + - 'but HTML doesn\'t differentiate between upper and ' + - 'lower case. You should use hyphen-delimited ' + - 'attribute names. For more info see ' + - 'http://vuejs.org/api/options.html#props' - ) - } - if (!identRE.test(path)) { - _.warn( - 'Invalid prop key: "' + name + '". Prop keys ' + - 'must be valid identifiers.' - ) - } - value = attrs[name] - /* jshint eqeqeq:false */ - if (value != null) { - prop = { - name: name, - raw: value, - path: path - } - var tokens = textParser.parse(value) - if (tokens) { - if (el && el.nodeType === 1) { - el.removeAttribute(name) - } - // important so that this doesn't get compiled - // again as a normal attribute binding - attrs[name] = null - prop.dynamic = true - prop.parentPath = textParser.tokensToExp(tokens) - // check prop binding type. - single = tokens.length === 1 - literal = literalValueRE.test(prop.parentPath) - // one time: {{* prop}} - prop.oneTime = - literal || - (single && tokens[0].oneTime) - // check one-way bindings - if (!prop.oneTime) { - settable = !literal && settablePathRE.test(prop.parentPath) - // one way down: {{> prop}} - prop.oneWayDown = - !settable || - (single && tokens[0].oneWay === 60) // < - // one way up: {{< prop}} - prop.oneWayUp = - single && - settable && - tokens[0].oneWay === 62 // > - } - } - 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) { - var i = props.length - var prop, path - while (i--) { - prop = props[i] - path = prop.path - if (prop.dynamic) { - if (vm.$parent) { - if (prop.oneTime) { - // one time binding - vm.$set(path, vm.$parent.$get(prop.parentPath)) - } else { - // dynamic binding - vm._bindDir('prop', el, prop, propDef) - } - } else { - _.warn( - 'Cannot bind dynamic prop on a root instance' + - ' with no parent: ' + prop.name + '="' + - prop.raw + '"' - ) - } - } else { - // literal, just set once - vm.$set(path, _.toNumber(prop.raw)) - } - } - } - } - - /** - * 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() - 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 - * @return {Function|undefined} - */ - - function checkComponent (el, options) { - var componentId = _.checkComponent(el, options) - 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 - /* jshint boss: true */ - 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 {Element|Object} elOrAttrs - * - could be an object of already-extracted - * container attributes. - * @param {Object} options - * @return {Function} - */ - - function compileDirectives (elOrAttrs, options) { - var attrs = _.isPlainObject(elOrAttrs) - ? mapToList(elOrAttrs) - : elOrAttrs.attributes - 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 (value === null) continue - if (name.indexOf(config.prefix) === 0) { - dirName = name.slice(config.prefix.length) - dirDef = resolveAsset(options, 'directives', dirName) - _.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) - } - } - - /** - * 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. - * - * @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. - * - * @param {String} name - * @param {String} value - * @param {Object} options - * @return {Object} - */ - - function collectAttrDirective (name, value, options) { - var tokens = textParser.parse(value) - if (tokens) { - var def = options.directives.attr - 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 value = textParser.tokensToExp(tokens, vm) - var desc = dirParser.parse(name + ':' + value)[0] - vm._bindDir('attr', 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 - } - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - var _ = __webpack_require__(2) - 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, - '', - '' - ] - - 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 - /* jshint boss:true */ - while (child = node.firstChild) { - 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 ( - _.isTemplate(node) && - node.content instanceof DocumentFragment - ) { - 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 - /* jshint boss:true */ - while (child = clone.firstChild) { - frag.appendChild(child) - } - 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