.'
+ );
+ }
+ }
+ addAttr(el, name, JSON.stringify(value));
+ // #4530 also bind special attributes as props even if they are static
+ // so that patches between dynamic/static are consistent
+ if (platformMustUseProp(el.tag, name)) {
+ if (name === 'value') {
+ addProp(el, name, JSON.stringify(value));
+ } else {
+ addProp(el, name, 'true');
}
}
- return this;
- };
-
- /**
- * Recursively propagate an event up the parent chain.
- *
- * @param {String} event
- * @param {...*} additional arguments
- */
-
- Vue.prototype.$dispatch = function (event) {
- var shouldPropagate = this.$emit.apply(this, arguments);
- if (!shouldPropagate) return;
- var parent = this.$parent;
- var args = toArray(arguments);
- // use object event to indicate non-source emit
- // on parents
- args[0] = { name: event, source: this };
- while (parent) {
- shouldPropagate = parent.$emit.apply(parent, args);
- parent = shouldPropagate ? parent.$parent : null;
- }
- return this;
- };
+ }
+ }
+ }
- /**
- * Modify the listener counts on all parents.
- * This bookkeeping allows $broadcast to return early when
- * no child has listened to a certain event.
- *
- * @param {Vue} vm
- * @param {String} event
- * @param {Number} count
- */
-
- var hookRE = /^hook:/;
- function modifyListenerCount(vm, event, count) {
- var parent = vm.$parent;
- // hooks do not get broadcasted so no need
- // to do bookkeeping for them
- if (!parent || !count || hookRE.test(event)) return;
- while (parent) {
- parent._eventsCount[event] = (parent._eventsCount[event] || 0) + count;
- parent = parent.$parent;
- }
- }
- }
-
- function lifecycleAPI (Vue) {
- /**
- * Set instance target element and kick off the compilation
- * process. The passed in `el` can be a selector string, an
- * existing Element, or a DocumentFragment (for block
- * instances).
- *
- * @param {Element|DocumentFragment|string} el
- * @public
- */
-
- Vue.prototype.$mount = function (el) {
- if (this._isCompiled) {
- 'development' !== 'production' && warn('$mount() should be called only once.', this);
- return;
- }
- el = query(el);
- if (!el) {
- el = document.createElement('div');
- }
- this._compile(el);
- this._initDOMHooks();
- if (inDoc(this.$el)) {
- this._callHook('attached');
- ready.call(this);
- } else {
- this.$once('hook:attached', ready);
- }
- return this;
- };
+ function checkInFor (el) {
+ var parent = el;
+ while (parent) {
+ if (parent.for !== undefined) {
+ return true
+ }
+ parent = parent.parent;
+ }
+ return false
+ }
- /**
- * Mark an instance as ready.
- */
+ function parseModifiers (name) {
+ var match = name.match(modifierRE);
+ if (match) {
+ var ret = {};
+ match.forEach(function (m) { ret[m.slice(1)] = true; });
+ return ret
+ }
+ }
- function ready() {
- this._isAttached = true;
- this._isReady = true;
- this._callHook('ready');
+ function makeAttrsMap (attrs) {
+ var map = {};
+ for (var i = 0, l = attrs.length; i < l; i++) {
+ if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE) {
+ warn$1('duplicate attribute: ' + attrs[i].name);
}
+ map[attrs[i].name] = attrs[i].value;
+ }
+ return map
+ }
- /**
- * Teardown the instance, simply delegate to the internal
- * _destroy.
- *
- * @param {Boolean} remove
- * @param {Boolean} deferCleanup
- */
+ function isForbiddenTag (el) {
+ return (
+ el.tag === 'style' ||
+ (el.tag === 'script' && (
+ !el.attrsMap.type ||
+ el.attrsMap.type === 'text/javascript'
+ ))
+ )
+ }
- Vue.prototype.$destroy = function (remove, deferCleanup) {
- this._destroy(remove, deferCleanup);
- };
+ var ieNSBug = /^xmlns:NS\d+/;
+ var ieNSPrefix = /^NS\d+:/;
- /**
- * Partially compile a piece of DOM and return a
- * decompile function.
- *
- * @param {Element|DocumentFragment} el
- * @param {Vue} [host]
- * @param {Object} [scope]
- * @param {Fragment} [frag]
- * @return {Function}
- */
-
- Vue.prototype.$compile = function (el, host, scope, frag) {
- return compile(el, this.$options, true)(this, el, host, scope, frag);
- };
+ /* istanbul ignore next */
+ function guardIESVGBug (attrs) {
+ var res = [];
+ for (var i = 0; i < attrs.length; i++) {
+ var attr = attrs[i];
+ if (!ieNSBug.test(attr.name)) {
+ attr.name = attr.name.replace(ieNSPrefix, '');
+ res.push(attr);
+ }
}
+ return res
+ }
- /**
- * The exposed Vue constructor.
- *
- * API conventions:
- * - public API methods/properties are prefixed 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);
+ function checkForAliasModel (el, value) {
+ var _el = el;
+ while (_el) {
+ if (_el.for && _el.alias === value) {
+ warn$1(
+ "<" + (el.tag) + " v-model=\"" + value + "\">: " +
+ "You are binding v-model directly to a v-for iteration alias. " +
+ "This will not be able to modify the v-for source array because " +
+ "writing to the alias is like modifying a function local variable. " +
+ "Consider using an array of objects and use v-model on an object property instead."
+ );
+ }
+ _el = _el.parent;
}
+ }
- // install internals
- initMixin(Vue);
- stateMixin(Vue);
- eventsMixin(Vue);
- lifecycleMixin(Vue);
- miscMixin(Vue);
+ /* */
- // install instance APIs
- dataAPI(Vue);
- domAPI(Vue);
- eventsAPI(Vue);
- lifecycleAPI(Vue);
+ var isStaticKey;
+ var isPlatformReservedTag;
- var slot = {
+ var genStaticKeysCached = cached(genStaticKeys$1);
- priority: SLOT,
- params: ['name'],
-
- bind: function bind() {
- // this was resolved during component transclusion
- var name = this.params.name || 'default';
- var content = this.vm._slotContents && this.vm._slotContents[name];
- if (!content || !content.hasChildNodes()) {
- this.fallback();
- } else {
- this.compile(content.cloneNode(true), this.vm._context, this.vm);
+ /**
+ * Goal of the optimizer: walk the generated template AST tree
+ * and detect sub-trees that are purely static, i.e. parts of
+ * the DOM that never needs to change.
+ *
+ * Once we detect these sub-trees, we can:
+ *
+ * 1. Hoist them into constants, so that we no longer need to
+ * create fresh nodes for them on each re-render;
+ * 2. Completely skip them in the patching process.
+ */
+ function optimize (root, options) {
+ if (!root) { return }
+ isStaticKey = genStaticKeysCached(options.staticKeys || '');
+ isPlatformReservedTag = options.isReservedTag || no;
+ // first pass: mark all non-static nodes.
+ markStatic(root);
+ // second pass: mark static roots.
+ markStaticRoots(root, false);
+ }
+
+ function genStaticKeys$1 (keys) {
+ return makeMap(
+ 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
+ (keys ? ',' + keys : '')
+ )
+ }
+
+ function markStatic (node) {
+ node.static = isStatic(node);
+ if (node.type === 1) {
+ // do not make component slot content static. this avoids
+ // 1. components not able to mutate slot nodes
+ // 2. static slot content fails for hot-reloading
+ if (
+ !isPlatformReservedTag(node.tag) &&
+ node.tag !== 'slot' &&
+ node.attrsMap['inline-template'] == null
+ ) {
+ return
+ }
+ for (var i = 0, l = node.children.length; i < l; i++) {
+ var child = node.children[i];
+ markStatic(child);
+ if (!child.static) {
+ node.static = false;
}
- },
+ }
+ }
+ }
- compile: function compile(content, context, host) {
- if (content && context) {
- if (this.el.hasChildNodes() && content.childNodes.length === 1 && content.childNodes[0].nodeType === 1 && content.childNodes[0].hasAttribute('v-if')) {
- // if the inserted slot has v-if
- // inject fallback content as the v-else
- var elseBlock = document.createElement('template');
- elseBlock.setAttribute('v-else', '');
- elseBlock.innerHTML = this.el.innerHTML;
- // the else block should be compiled in child scope
- elseBlock._context = this.vm;
- content.appendChild(elseBlock);
- }
- var scope = host ? host._scope : this._scope;
- this.unlink = context.$compile(content, host, scope, this._frag);
- }
- if (content) {
- replace(this.el, content);
- } else {
- remove(this.el);
+ function markStaticRoots (node, isInFor) {
+ if (node.type === 1) {
+ if (node.static || node.once) {
+ node.staticInFor = isInFor;
+ }
+ // For a node to qualify as a static root, it should have children that
+ // are not just static text. Otherwise the cost of hoisting out will
+ // outweigh the benefits and it's better off to just always render it fresh.
+ if (node.static && node.children.length && !(
+ node.children.length === 1 &&
+ node.children[0].type === 3
+ )) {
+ node.staticRoot = true;
+ return
+ } else {
+ node.staticRoot = false;
+ }
+ if (node.children) {
+ for (var i = 0, l = node.children.length; i < l; i++) {
+ markStaticRoots(node.children[i], isInFor || !!node.for);
}
- },
+ }
+ if (node.ifConditions) {
+ walkThroughConditionsBlocks(node.ifConditions, isInFor);
+ }
+ }
+ }
- fallback: function fallback() {
- this.compile(extractContent(this.el, true), this.vm);
- },
+ function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
+ for (var i = 1, len = conditionBlocks.length; i < len; i++) {
+ markStaticRoots(conditionBlocks[i].block, isInFor);
+ }
+ }
- unbind: function unbind() {
- if (this.unlink) {
- this.unlink();
- }
+ function isStatic (node) {
+ if (node.type === 2) { // expression
+ return false
+ }
+ if (node.type === 3) { // text
+ return true
+ }
+ return !!(node.pre || (
+ !node.hasBindings && // no dynamic bindings
+ !node.if && !node.for && // not v-if or v-for or v-else
+ !isBuiltInTag(node.tag) && // not a built-in
+ isPlatformReservedTag(node.tag) && // not a component
+ !isDirectChildOfTemplateFor(node) &&
+ Object.keys(node).every(isStaticKey)
+ ))
+ }
+
+ function isDirectChildOfTemplateFor (node) {
+ while (node.parent) {
+ node = node.parent;
+ if (node.tag !== 'template') {
+ return false
}
- };
+ if (node.for) {
+ return true
+ }
+ }
+ return false
+ }
- var partial = {
+ /* */
- priority: PARTIAL,
+ var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
+ var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
- params: ['name'],
+ // keyCode aliases
+ var keyCodes = {
+ esc: 27,
+ tab: 9,
+ enter: 13,
+ space: 32,
+ up: 38,
+ left: 37,
+ right: 39,
+ down: 40,
+ 'delete': [8, 46]
+ };
- // watch changes to name for dynamic partials
- paramWatchers: {
- name: function name(value) {
- vIf.remove.call(this);
- if (value) {
- this.insert(value);
- }
+ var modifierCode = {
+ stop: '$event.stopPropagation();',
+ prevent: '$event.preventDefault();',
+ self: 'if($event.target !== $event.currentTarget)return;',
+ ctrl: 'if(!$event.ctrlKey)return;',
+ shift: 'if(!$event.shiftKey)return;',
+ alt: 'if(!$event.altKey)return;',
+ meta: 'if(!$event.metaKey)return;'
+ };
+
+ function genHandlers (events, native) {
+ var res = native ? 'nativeOn:{' : 'on:{';
+ for (var name in events) {
+ res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
+ }
+ return res.slice(0, -1) + '}'
+ }
+
+ function genHandler (
+ name,
+ handler
+ ) {
+ if (!handler) {
+ return 'function(){}'
+ } else if (Array.isArray(handler)) {
+ return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
+ } else if (!handler.modifiers) {
+ return fnExpRE.test(handler.value) || simplePathRE.test(handler.value)
+ ? handler.value
+ : ("function($event){" + (handler.value) + "}")
+ } else {
+ var code = '';
+ var keys = [];
+ for (var key in handler.modifiers) {
+ if (modifierCode[key]) {
+ code += modifierCode[key];
+ } else {
+ keys.push(key);
}
- },
+ }
+ if (keys.length) {
+ code = genKeyFilter(keys) + code;
+ }
+ var handlerCode = simplePathRE.test(handler.value)
+ ? handler.value + '($event)'
+ : handler.value;
+ return 'function($event){' + code + handlerCode + '}'
+ }
+ }
- bind: function bind() {
- this.anchor = createAnchor('v-partial');
- replace(this.el, this.anchor);
- this.insert(this.params.name);
- },
+ function genKeyFilter (keys) {
+ return ("if(" + (keys.map(genFilterCode).join('&&')) + ")return;")
+ }
- insert: function insert(id) {
- var partial = resolveAsset(this.vm.$options, 'partials', id, true);
- if (partial) {
- this.factory = new FragmentFactory(this.vm, partial);
- vIf.insert.call(this);
- }
- },
+ function genFilterCode (key) {
+ var keyVal = parseInt(key, 10);
+ if (keyVal) {
+ return ("$event.keyCode!==" + keyVal)
+ }
+ var alias = keyCodes[key];
+ return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
+ }
- unbind: function unbind() {
- if (this.frag) {
- this.frag.destroy();
- }
- }
- };
+ /* */
- var elementDirectives = {
- slot: slot,
- partial: partial
+ function bind$2 (el, dir) {
+ el.wrapData = function (code) {
+ return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
};
+ }
- var convertArray = vFor._postProcess;
+ var baseDirectives = {
+ bind: bind$2,
+ cloak: noop
+ };
- /**
- * Limit filter for arrays
- *
- * @param {Number} n
- * @param {Number} offset (Decimal expected)
- */
+ /* */
+
+ // configurable state
+ var warn$2;
+ var transforms$1;
+ var dataGenFns;
+ var platformDirectives$1;
+ var isPlatformReservedTag$1;
+ var staticRenderFns;
+ var onceCount;
+ var currentOptions;
+
+ function generate (
+ ast,
+ options
+ ) {
+ // save previous staticRenderFns so generate calls can be nested
+ var prevStaticRenderFns = staticRenderFns;
+ var currentStaticRenderFns = staticRenderFns = [];
+ var prevOnceCount = onceCount;
+ onceCount = 0;
+ currentOptions = options;
+ warn$2 = options.warn || baseWarn;
+ transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
+ dataGenFns = pluckModuleFunction(options.modules, 'genData');
+ platformDirectives$1 = options.directives || {};
+ isPlatformReservedTag$1 = options.isReservedTag || no;
+ var code = ast ? genElement(ast) : '_c("div")';
+ staticRenderFns = prevStaticRenderFns;
+ onceCount = prevOnceCount;
+ return {
+ render: ("with(this){return " + code + "}"),
+ staticRenderFns: currentStaticRenderFns
+ }
+ }
+
+ function genElement (el) {
+ if (el.staticRoot && !el.staticProcessed) {
+ return genStatic(el)
+ } else if (el.once && !el.onceProcessed) {
+ return genOnce(el)
+ } else if (el.for && !el.forProcessed) {
+ return genFor(el)
+ } else if (el.if && !el.ifProcessed) {
+ return genIf(el)
+ } else if (el.tag === 'template' && !el.slotTarget) {
+ return genChildren(el) || 'void 0'
+ } else if (el.tag === 'slot') {
+ return genSlot(el)
+ } else {
+ // component or element
+ var code;
+ if (el.component) {
+ code = genComponent(el.component, el);
+ } else {
+ var data = el.plain ? undefined : genData(el);
+
+ var children = el.inlineTemplate ? null : genChildren(el, true);
+ code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
+ }
+ // module transforms
+ for (var i = 0; i < transforms$1.length; i++) {
+ code = transforms$1[i](el, code);
+ }
+ return code
+ }
+ }
+
+ // hoist static sub-trees out
+ function genStatic (el) {
+ el.staticProcessed = true;
+ staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
+ return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
+ }
+
+ // v-once
+ function genOnce (el) {
+ el.onceProcessed = true;
+ if (el.if && !el.ifProcessed) {
+ return genIf(el)
+ } else if (el.staticInFor) {
+ var key = '';
+ var parent = el.parent;
+ while (parent) {
+ if (parent.for) {
+ key = parent.key;
+ break
+ }
+ parent = parent.parent;
+ }
+ if (!key) {
+ process.env.NODE_ENV !== 'production' && warn$2(
+ "v-once can only be used inside v-for that is keyed. "
+ );
+ return genElement(el)
+ }
+ return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
+ } else {
+ return genStatic(el)
+ }
+ }
+
+ function genIf (el) {
+ el.ifProcessed = true; // avoid recursion
+ return genIfConditions(el.ifConditions.slice())
+ }
- function limitBy(arr, n, offset) {
- offset = offset ? parseInt(offset, 10) : 0;
- n = toNumber(n);
- return typeof n === 'number' ? arr.slice(offset, offset + n) : arr;
+ function genIfConditions (conditions) {
+ if (!conditions.length) {
+ return '_e()'
}
- /**
- * Filter filter for arrays
- *
- * @param {String} search
- * @param {String} [delimiter]
- * @param {String} ...dataKeys
- */
+ var condition = conditions.shift();
+ if (condition.exp) {
+ return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
+ } else {
+ return ("" + (genTernaryExp(condition.block)))
+ }
+
+ // v-if with v-once should generate code like (a)?_m(0):_m(1)
+ function genTernaryExp (el) {
+ return el.once ? genOnce(el) : genElement(el)
+ }
+ }
+
+ function genFor (el) {
+ var exp = el.for;
+ var alias = el.alias;
+ var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
+ var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
+ el.forProcessed = true; // avoid recursion
+ return "_l((" + exp + ")," +
+ "function(" + alias + iterator1 + iterator2 + "){" +
+ "return " + (genElement(el)) +
+ '})'
+ }
+
+ function genData (el) {
+ var data = '{';
+
+ // directives first.
+ // directives may mutate the el's other properties before they are generated.
+ var dirs = genDirectives(el);
+ if (dirs) { data += dirs + ','; }
+
+ // key
+ if (el.key) {
+ data += "key:" + (el.key) + ",";
+ }
+ // ref
+ if (el.ref) {
+ data += "ref:" + (el.ref) + ",";
+ }
+ if (el.refInFor) {
+ data += "refInFor:true,";
+ }
+ // pre
+ if (el.pre) {
+ data += "pre:true,";
+ }
+ // record original tag name for components using "is" attribute
+ if (el.component) {
+ data += "tag:\"" + (el.tag) + "\",";
+ }
+ // module data generation functions
+ for (var i = 0; i < dataGenFns.length; i++) {
+ data += dataGenFns[i](el);
+ }
+ // attributes
+ if (el.attrs) {
+ data += "attrs:{" + (genProps(el.attrs)) + "},";
+ }
+ // DOM props
+ if (el.props) {
+ data += "domProps:{" + (genProps(el.props)) + "},";
+ }
+ // event handlers
+ if (el.events) {
+ data += (genHandlers(el.events)) + ",";
+ }
+ if (el.nativeEvents) {
+ data += (genHandlers(el.nativeEvents, true)) + ",";
+ }
+ // slot target
+ if (el.slotTarget) {
+ data += "slot:" + (el.slotTarget) + ",";
+ }
+ // scoped slots
+ if (el.scopedSlots) {
+ data += (genScopedSlots(el.scopedSlots)) + ",";
+ }
+ // inline-template
+ if (el.inlineTemplate) {
+ var inlineTemplate = genInlineTemplate(el);
+ if (inlineTemplate) {
+ data += inlineTemplate + ",";
+ }
+ }
+ data = data.replace(/,$/, '') + '}';
+ // v-bind data wrap
+ if (el.wrapData) {
+ data = el.wrapData(data);
+ }
+ return data
+ }
+
+ function genDirectives (el) {
+ var dirs = el.directives;
+ if (!dirs) { return }
+ var res = 'directives:[';
+ var hasRuntime = false;
+ var i, l, dir, needRuntime;
+ for (i = 0, l = dirs.length; i < l; i++) {
+ dir = dirs[i];
+ needRuntime = true;
+ var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name];
+ if (gen) {
+ // compile-time directive that manipulates AST.
+ // returns true if it also needs a runtime counterpart.
+ needRuntime = !!gen(el, dir, warn$2);
+ }
+ if (needRuntime) {
+ hasRuntime = true;
+ res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
+ }
+ }
+ if (hasRuntime) {
+ return res.slice(0, -1) + ']'
+ }
+ }
+
+ function genInlineTemplate (el) {
+ var ast = el.children[0];
+ if (process.env.NODE_ENV !== 'production' && (
+ el.children.length > 1 || ast.type !== 1
+ )) {
+ warn$2('Inline-template components must have exactly one child element.');
+ }
+ if (ast.type === 1) {
+ var inlineRenderFns = generate(ast, currentOptions);
+ return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
+ }
+ }
+
+ function genScopedSlots (slots) {
+ return ("scopedSlots:{" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "}")
+ }
+
+ function genScopedSlot (key, el) {
+ return key + ":function(" + (String(el.attrsMap.scope)) + "){" +
+ "return " + (el.tag === 'template'
+ ? genChildren(el) || 'void 0'
+ : genElement(el)) + "}"
+ }
+
+ function genChildren (el, checkSkip) {
+ var children = el.children;
+ if (children.length) {
+ var el$1 = children[0];
+ // optimize single v-for
+ if (children.length === 1 &&
+ el$1.for &&
+ el$1.tag !== 'template' &&
+ el$1.tag !== 'slot') {
+ return genElement(el$1)
+ }
+ var normalizationType = getNormalizationType(children);
+ return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip
+ ? normalizationType ? ("," + normalizationType) : ''
+ : ''))
+ }
+ }
+
+ // determine the normalzation needed for the children array.
+ // 0: no normalization needed
+ // 1: simple normalization needed (possible 1-level deep nested array)
+ // 2: full nomralization needed
+ function getNormalizationType (children) {
+ for (var i = 0; i < children.length; i++) {
+ var el = children[i];
+ if (needsNormalization(el) ||
+ (el.if && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
+ return 2
+ }
+ if (maybeComponent(el) ||
+ (el.if && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
+ return 1
+ }
+ }
+ return 0
+ }
+
+ function needsNormalization (el) {
+ return el.for || el.tag === 'template' || el.tag === 'slot'
+ }
+
+ function maybeComponent (el) {
+ return el.type === 1 && !isPlatformReservedTag$1(el.tag)
+ }
+
+ function genNode (node) {
+ if (node.type === 1) {
+ return genElement(node)
+ } else {
+ return genText(node)
+ }
+ }
+
+ function genText (text) {
+ return ("_v(" + (text.type === 2
+ ? text.expression // no need for () because already wrapped in _s()
+ : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
+ }
+
+ function genSlot (el) {
+ var slotName = el.slotName || '"default"';
+ var children = genChildren(el);
+ var res = "_t(" + slotName + (children ? ("," + children) : '');
+ var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
+ var bind$$1 = el.attrsMap['v-bind'];
+ if ((attrs || bind$$1) && !children) {
+ res += ",null";
+ }
+ if (attrs) {
+ res += "," + attrs;
+ }
+ if (bind$$1) {
+ res += (attrs ? '' : ',null') + "," + bind$$1;
+ }
+ return res + ')'
+ }
+
+ // componentName is el.component, take it as argument to shun flow's pessimistic refinement
+ function genComponent (componentName, el) {
+ var children = el.inlineTemplate ? null : genChildren(el, true);
+ return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
+ }
+
+ function genProps (props) {
+ var res = '';
+ for (var i = 0; i < props.length; i++) {
+ var prop = props[i];
+ res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
+ }
+ return res.slice(0, -1)
+ }
+
+ // #3895, #4268
+ function transformSpecialNewlines (text) {
+ return text
+ .replace(/\u2028/g, '\\u2028')
+ .replace(/\u2029/g, '\\u2029')
+ }
+
+ /* */
- function filterBy(arr, search, delimiter) {
- arr = convertArray(arr);
- if (search == null) {
- return arr;
- }
- if (typeof search === 'function') {
- return arr.filter(search);
- }
- // cast to lowercase string
- search = ('' + search).toLowerCase();
- // allow optional `in` delimiter
- // because why not
- var n = delimiter === 'in' ? 3 : 2;
- // extract and flatten keys
- var keys = Array.prototype.concat.apply([], toArray(arguments, n));
- var res = [];
- var item, key, val, j;
- for (var i = 0, l = arr.length; i < l; i++) {
- item = arr[i];
- val = item && item.$value || item;
- j = keys.length;
- if (j) {
- while (j--) {
- key = keys[j];
- if (key === '$key' && contains(item.$key, search) || contains(getPath(val, key), search)) {
- res.push(item);
- break;
+ /**
+ * Compile a template.
+ */
+ function compile$1 (
+ template,
+ options
+ ) {
+ var ast = parse(template.trim(), options);
+ optimize(ast, options);
+ var code = generate(ast, options);
+ return {
+ ast: ast,
+ render: code.render,
+ staticRenderFns: code.staticRenderFns
+ }
+ }
+
+ /* */
+
+ // operators like typeof, instanceof and in are allowed
+ var prohibitedKeywordRE = new RegExp('\\b' + (
+ 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
+ 'super,throw,while,yield,delete,export,import,return,switch,default,' +
+ 'extends,finally,continue,debugger,function,arguments'
+ ).split(',').join('\\b|\\b') + '\\b');
+ // check valid identifier for v-for
+ var identRE = /[A-Za-z_$][\w$]*/;
+ // strip strings in expressions
+ var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
+
+ // detect problematic expressions in a template
+ function detectErrors (ast) {
+ var errors = [];
+ if (ast) {
+ checkNode(ast, errors);
+ }
+ return errors
+ }
+
+ function checkNode (node, errors) {
+ if (node.type === 1) {
+ for (var name in node.attrsMap) {
+ if (dirRE.test(name)) {
+ var value = node.attrsMap[name];
+ if (value) {
+ if (name === 'v-for') {
+ checkFor(node, ("v-for=\"" + value + "\""), errors);
+ } else {
+ checkExpression(value, (name + "=\"" + value + "\""), errors);
}
}
- } else if (contains(item, search)) {
- res.push(item);
}
}
- return res;
+ if (node.children) {
+ for (var i = 0; i < node.children.length; i++) {
+ checkNode(node.children[i], errors);
+ }
+ }
+ } else if (node.type === 2) {
+ checkExpression(node.expression, node.text, errors);
}
+ }
- /**
- * Filter filter for arrays
- *
- * @param {String|Array
|Function} ...sortKeys
- * @param {Number} [order]
- */
+ function checkFor (node, text, errors) {
+ checkExpression(node.for || '', text, errors);
+ checkIdentifier(node.alias, 'v-for alias', text, errors);
+ checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
+ checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
+ }
- function orderBy(arr) {
- var comparator = null;
- var sortKeys = undefined;
- arr = convertArray(arr);
+ function checkIdentifier (ident, type, text, errors) {
+ if (typeof ident === 'string' && !identRE.test(ident)) {
+ errors.push(("- invalid " + type + " \"" + ident + "\" in expression: " + text));
+ }
+ }
- // determine order (last argument)
- var args = toArray(arguments, 1);
- var order = args[args.length - 1];
- if (typeof order === 'number') {
- order = order < 0 ? -1 : 1;
- args = args.length > 1 ? args.slice(0, -1) : args;
+ function checkExpression (exp, text, errors) {
+ try {
+ new Function(("return " + exp));
+ } catch (e) {
+ var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
+ if (keywordMatch) {
+ errors.push(
+ "- avoid using JavaScript keyword as property name: " +
+ "\"" + (keywordMatch[0]) + "\" in expression " + text
+ );
} else {
- order = 1;
+ errors.push(("- invalid expression: " + text));
}
+ }
+ }
- // determine sortKeys & comparator
- var firstArg = args[0];
- if (!firstArg) {
- return arr;
- } else if (typeof firstArg === 'function') {
- // custom comparator
- comparator = function (a, b) {
- return firstArg(a, b) * order;
- };
- } else {
- // string keys. flatten first
- sortKeys = Array.prototype.concat.apply([], args);
- comparator = function (a, b, i) {
- i = i || 0;
- return i >= sortKeys.length - 1 ? baseCompare(a, b, i) : baseCompare(a, b, i) || comparator(a, b, i + 1);
- };
- }
+ /* */
- function baseCompare(a, b, sortKeyIndex) {
- var sortKey = sortKeys[sortKeyIndex];
- if (sortKey) {
- if (sortKey !== '$key') {
- if (isObject(a) && '$value' in a) a = a.$value;
- if (isObject(b) && '$value' in b) b = b.$value;
- }
- a = isObject(a) ? getPath(a, sortKey) : a;
- b = isObject(b) ? getPath(b, sortKey) : b;
- }
- return a === b ? 0 : a > b ? order : -order;
+ function transformNode (el, options) {
+ var warn = options.warn || baseWarn;
+ var staticClass = getAndRemoveAttr(el, 'class');
+ if (process.env.NODE_ENV !== 'production' && staticClass) {
+ var expression = parseText(staticClass, options.delimiters);
+ if (expression) {
+ warn(
+ "class=\"" + staticClass + "\": " +
+ 'Interpolation inside attributes has been removed. ' +
+ 'Use v-bind or the colon shorthand instead. For example, ' +
+ 'instead of , use
.'
+ );
}
+ }
+ if (staticClass) {
+ el.staticClass = JSON.stringify(staticClass);
+ }
+ var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
+ if (classBinding) {
+ el.classBinding = classBinding;
+ }
+ }
- // sort on a copy to avoid mutating original array
- return arr.slice().sort(comparator);
+ function genData$1 (el) {
+ var data = '';
+ if (el.staticClass) {
+ data += "staticClass:" + (el.staticClass) + ",";
}
+ if (el.classBinding) {
+ data += "class:" + (el.classBinding) + ",";
+ }
+ return data
+ }
- /**
- * String contain helper
- *
- * @param {*} val
- * @param {String} search
- */
+ var klass$1 = {
+ staticKeys: ['staticClass'],
+ transformNode: transformNode,
+ genData: genData$1
+ };
- function contains(val, search) {
- var i;
- if (isPlainObject(val)) {
- var keys = Object.keys(val);
- i = keys.length;
- while (i--) {
- if (contains(val[keys[i]], search)) {
- return true;
- }
- }
- } else if (isArray(val)) {
- i = val.length;
- while (i--) {
- if (contains(val[i], search)) {
- return true;
- }
+ /* */
+
+ function transformNode$1 (el, options) {
+ var warn = options.warn || baseWarn;
+ var staticStyle = getAndRemoveAttr(el, 'style');
+ if (staticStyle) {
+ /* istanbul ignore if */
+ if (process.env.NODE_ENV !== 'production') {
+ var expression = parseText(staticStyle, options.delimiters);
+ if (expression) {
+ warn(
+ "style=\"" + staticStyle + "\": " +
+ 'Interpolation inside attributes has been removed. ' +
+ 'Use v-bind or the colon shorthand instead. For example, ' +
+ 'instead of
, use
.'
+ );
}
- } else if (val != null) {
- return val.toString().toLowerCase().indexOf(search) > -1;
}
+ el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
}
- var digitsRE = /(\d{3})(?=\d)/g;
+ var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
+ if (styleBinding) {
+ el.styleBinding = styleBinding;
+ }
+ }
- // asset collections must be a plain object.
- var filters = {
+ function genData$2 (el) {
+ var data = '';
+ if (el.staticStyle) {
+ data += "staticStyle:" + (el.staticStyle) + ",";
+ }
+ if (el.styleBinding) {
+ data += "style:(" + (el.styleBinding) + "),";
+ }
+ return data
+ }
- orderBy: orderBy,
- filterBy: filterBy,
- limitBy: limitBy,
+ var style$1 = {
+ staticKeys: ['staticStyle'],
+ transformNode: transformNode$1,
+ genData: genData$2
+ };
- /**
- * Stringify value.
- *
- * @param {Number} indent
- */
+ var modules$1 = [
+ klass$1,
+ style$1
+ ];
+
+ /* */
+
+ var warn$3;
+
+ function model$1 (
+ el,
+ dir,
+ _warn
+ ) {
+ warn$3 = _warn;
+ var value = dir.value;
+ var modifiers = dir.modifiers;
+ var tag = el.tag;
+ var type = el.attrsMap.type;
+ if (process.env.NODE_ENV !== 'production') {
+ var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
+ if (tag === 'input' && dynamicType) {
+ warn$3(
+ "
:\n" +
+ "v-model does not support dynamic input types. Use v-if branches instead."
+ );
+ }
+ }
+ if (tag === 'select') {
+ genSelect(el, value, modifiers);
+ } else if (tag === 'input' && type === 'checkbox') {
+ genCheckboxModel(el, value, modifiers);
+ } else if (tag === 'input' && type === 'radio') {
+ genRadioModel(el, value, modifiers);
+ } else {
+ genDefaultModel(el, value, modifiers);
+ }
+ // ensure runtime directive metadata
+ return true
+ }
+
+ function genCheckboxModel (
+ el,
+ value,
+ modifiers
+ ) {
+ if (process.env.NODE_ENV !== 'production' &&
+ el.attrsMap.checked != null) {
+ warn$3(
+ "<" + (el.tag) + " v-model=\"" + value + "\" checked>:\n" +
+ "inline checked attributes will be ignored when using v-model. " +
+ 'Declare initial values in the component\'s data option instead.'
+ );
+ }
+ var number = modifiers && modifiers.number;
+ var valueBinding = getBindingAttr(el, 'value') || 'null';
+ var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
+ var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
+ addProp(el, 'checked',
+ "Array.isArray(" + value + ")" +
+ "?_i(" + value + "," + valueBinding + ")>-1" +
+ ":_q(" + value + "," + trueValueBinding + ")"
+ );
+ addHandler(el, 'change',
+ "var $$a=" + value + "," +
+ '$$el=$event.target,' +
+ "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
+ 'if(Array.isArray($$a)){' +
+ "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
+ '$$i=_i($$a,$$v);' +
+ "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
+ "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
+ "}else{" + value + "=$$c}",
+ null, true
+ );
+ }
+
+ function genRadioModel (
+ el,
+ value,
+ modifiers
+ ) {
+ if (process.env.NODE_ENV !== 'production' &&
+ el.attrsMap.checked != null) {
+ warn$3(
+ "<" + (el.tag) + " v-model=\"" + value + "\" checked>:\n" +
+ "inline checked attributes will be ignored when using v-model. " +
+ 'Declare initial values in the component\'s data option instead.'
+ );
+ }
+ var number = modifiers && modifiers.number;
+ var valueBinding = getBindingAttr(el, 'value') || 'null';
+ valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
+ addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
+ addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
+ }
+
+ function genDefaultModel (
+ el,
+ value,
+ modifiers
+ ) {
+ if (process.env.NODE_ENV !== 'production') {
+ if (el.tag === 'input' && el.attrsMap.value) {
+ warn$3(
+ "<" + (el.tag) + " v-model=\"" + value + "\" value=\"" + (el.attrsMap.value) + "\">:\n" +
+ 'inline value attributes will be ignored when using v-model. ' +
+ 'Declare initial values in the component\'s data option instead.'
+ );
+ }
+ if (el.tag === 'textarea' && el.children.length) {
+ warn$3(
+ "