You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2017/01/24 08:21:42 UTC
[31/50] [abbrv] incubator-weex git commit: * [android] update jsfm to
v0.19.7 include RAX and Vue2.0 exclude strict mode (#136)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/405b6e67/android/sdk/assets/main.js
----------------------------------------------------------------------
diff --git a/android/sdk/assets/main.js b/android/sdk/assets/main.js
index 8cfe735..2fc8baf 100644
--- a/android/sdk/assets/main.js
+++ b/android/sdk/assets/main.js
@@ -1,5 +1,5 @@
-(this.nativeLog || function(s) {console.log(s)})('START JS FRAMEWORK 0.19.4, Build 2017-01-03 11:15.');
-(this.getJSFMVersion = function(){return "0.19.4"});var global = this, process = { env: {} };var setTimeout = global.setTimeout;
+(this.nativeLog || function(s) {console.log(s)})('START JS FRAMEWORK 0.19.7, Build 2017-01-10 10:50.');
+(this.getJSFMVersion = function(){return "0.19.7"});var global = this, process = { env: {} };var setTimeout = global.setTimeout;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
@@ -7,7 +7,7 @@
(factory());
}(this, (function () { 'use strict';
-var subversion = {"browser":"0.5.0","framework":"0.19.4","transformer":">=0.1.5 <0.5"};
+var subversion = {"browser":"0.5.0","framework":"0.19.7","transformer":">=0.1.5 <0.5"};
/* eslint-disable */
@@ -319,7 +319,7 @@ $export$1.P = 8; // proto
$export$1.B = 16; // bind
$export$1.W = 32; // wrap
$export$1.U = 64; // safe
-$export$1.R = 128; // real proto method for `library`
+$export$1.R = 128; // real proto method for `library`
var _export = $export$1;
var toString$1 = {}.toString;
@@ -4985,804 +4985,951 @@ var initProxy;
/* */
+var VNode = function VNode (
+ tag,
+ data,
+ children,
+ text,
+ elm,
+ context,
+ componentOptions
+) {
+ this.tag = tag;
+ this.data = data;
+ this.children = children;
+ this.text = text;
+ this.elm = elm;
+ this.ns = undefined;
+ this.context = context;
+ this.functionalContext = undefined;
+ this.key = data && data.key;
+ this.componentOptions = componentOptions;
+ this.child = undefined;
+ this.parent = undefined;
+ this.raw = false;
+ this.isStatic = false;
+ this.isRootInsert = true;
+ this.isComment = false;
+ this.isCloned = false;
+ this.isOnce = false;
+};
-var queue = [];
-var has$1 = {};
-var circular = {};
-var waiting = false;
-var flushing = false;
-var index = 0;
+var createEmptyVNode = function () {
+ var node = new VNode();
+ node.text = '';
+ node.isComment = true;
+ return node
+};
-/**
- * Reset the scheduler's state.
- */
-function resetSchedulerState () {
- queue.length = 0;
- has$1 = {};
- {
- circular = {};
+function createTextVNode (val) {
+ return new VNode(undefined, undefined, undefined, String(val))
+}
+
+// optimized shallow clone
+// used for static nodes and slot nodes because they may be reused across
+// multiple renders, cloning them avoids errors when DOM manipulations rely
+// on their elm reference.
+function cloneVNode (vnode) {
+ var cloned = new VNode(
+ vnode.tag,
+ vnode.data,
+ vnode.children,
+ vnode.text,
+ vnode.elm,
+ vnode.context,
+ vnode.componentOptions
+ );
+ cloned.ns = vnode.ns;
+ cloned.isStatic = vnode.isStatic;
+ cloned.key = vnode.key;
+ cloned.isCloned = true;
+ return cloned
+}
+
+function cloneVNodes (vnodes) {
+ var res = new Array(vnodes.length);
+ for (var i = 0; i < vnodes.length; i++) {
+ res[i] = cloneVNode(vnodes[i]);
}
- waiting = flushing = false;
+ return res
}
-/**
- * Flush both queues and run the watchers.
- */
-function flushSchedulerQueue () {
- flushing = true;
+/* */
- // Sort queue before flush.
- // This ensures that:
- // 1. Components are updated from parent to child. (because parent is always
- // created before the child)
- // 2. A component's user watchers are run before its render watcher (because
- // user watchers are created before the render watcher)
- // 3. If a component is destroyed during a parent component's watcher run,
- // its watchers can be skipped.
- queue.sort(function (a, b) { return a.id - b.id; });
+var hooks = { init: init$1, prepatch: prepatch, insert: insert, destroy: destroy$1 };
+var hooksToMerge = Object.keys(hooks);
- // do not cache length because more watchers might be pushed
- // as we run existing watchers
- for (index = 0; index < queue.length; index++) {
- var watcher = queue[index];
- var id = watcher.id;
- has$1[id] = null;
- watcher.run();
- // in dev build, check and stop circular updates.
- if ("development" !== 'production' && has$1[id] != null) {
- circular[id] = (circular[id] || 0) + 1;
- if (circular[id] > config._maxUpdateCount) {
- warn(
- 'You may have an infinite update loop ' + (
- watcher.user
- ? ("in watcher with expression \"" + (watcher.expression) + "\"")
- : "in a component render function."
- ),
- watcher.vm
- );
- break
- }
- }
+function createComponent (
+ Ctor,
+ data,
+ context,
+ children,
+ tag
+) {
+ if (!Ctor) {
+ return
}
- // devtool hook
- /* istanbul ignore if */
- if (devtools && config.devtools) {
- devtools.emit('flush');
+ var baseCtor = context.$options._base;
+ if (isObject(Ctor)) {
+ Ctor = baseCtor.extend(Ctor);
}
- resetSchedulerState();
-}
+ if (typeof Ctor !== 'function') {
+ {
+ warn(("Invalid Component definition: " + (String(Ctor))), context);
+ }
+ return
+ }
-/**
- * Push a watcher into the watcher queue.
- * Jobs with duplicate IDs will be skipped unless it's
- * pushed when the queue is being flushed.
- */
-function queueWatcher (watcher) {
- var id = watcher.id;
- if (has$1[id] == null) {
- has$1[id] = true;
- if (!flushing) {
- queue.push(watcher);
+ // async component
+ if (!Ctor.cid) {
+ if (Ctor.resolved) {
+ Ctor = Ctor.resolved;
} else {
- // if already flushing, splice the watcher based on its id
- // if already past its id, it will be run next immediately.
- var i = queue.length - 1;
- while (i >= 0 && queue[i].id > watcher.id) {
- i--;
+ Ctor = resolveAsyncComponent(Ctor, baseCtor, function () {
+ // it's ok to queue this on every render because
+ // $forceUpdate is buffered by the scheduler.
+ context.$forceUpdate();
+ });
+ if (!Ctor) {
+ // return nothing if this is indeed an async component
+ // wait for the callback to trigger parent update.
+ return
}
- queue.splice(Math.max(i, index) + 1, 0, watcher);
- }
- // queue the flush
- if (!waiting) {
- waiting = true;
- nextTick(flushSchedulerQueue);
}
}
-}
-/* */
+ // resolve constructor options in case global mixins are applied after
+ // component constructor creation
+ resolveConstructorOptions(Ctor);
-var uid$2 = 0;
+ data = data || {};
-/**
- * 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.
- */
-var Watcher = function Watcher (
- vm,
- expOrFn,
- cb,
- options
-) {
- this.vm = vm;
- vm._watchers.push(this);
- // options
- if (options) {
- this.deep = !!options.deep;
- this.user = !!options.user;
- this.lazy = !!options.lazy;
- this.sync = !!options.sync;
- } else {
- this.deep = this.user = this.lazy = this.sync = false;
- }
- this.cb = cb;
- this.id = ++uid$2; // uid for batching
- this.active = true;
- this.dirty = this.lazy; // for lazy watchers
- this.deps = [];
- this.newDeps = [];
- this.depIds = new _Set();
- this.newDepIds = new _Set();
- this.expression = expOrFn.toString();
- // parse expression for getter
- if (typeof expOrFn === 'function') {
- this.getter = expOrFn;
- } else {
- this.getter = parsePath(expOrFn);
- if (!this.getter) {
- this.getter = function () {};
- "development" !== 'production' && warn(
- "Failed watching path: \"" + expOrFn + "\" " +
- 'Watcher only accepts simple dot-delimited paths. ' +
- 'For full control, use a function instead.',
- vm
- );
- }
- }
- this.value = this.lazy
- ? undefined
- : this.get();
-};
+ // extract props
+ var propsData = extractProps(data, Ctor);
-/**
- * Evaluate the getter, and re-collect dependencies.
- */
-Watcher.prototype.get = function get () {
- pushTarget(this);
- var value = this.getter.call(this.vm, this.vm);
- // "touch" every property so they are all tracked as
- // dependencies for deep watching
- if (this.deep) {
- traverse(value);
+ // functional component
+ if (Ctor.options.functional) {
+ return createFunctionalComponent(Ctor, propsData, data, context, children)
}
- popTarget();
- this.cleanupDeps();
- return value
-};
-/**
- * Add a dependency to this directive.
- */
-Watcher.prototype.addDep = function addDep (dep) {
- var id = dep.id;
- if (!this.newDepIds.has(id)) {
- this.newDepIds.add(id);
- this.newDeps.push(dep);
- if (!this.depIds.has(id)) {
- dep.addSub(this);
- }
+ // extract listeners, since these needs to be treated as
+ // child component listeners instead of DOM listeners
+ var listeners = data.on;
+ // replace with listeners with .native modifier
+ data.on = data.nativeOn;
+
+ if (Ctor.options.abstract) {
+ // abstract components do not keep anything
+ // other than props & listeners
+ data = {};
}
-};
-/**
- * Clean up for dependency collection.
- */
-Watcher.prototype.cleanupDeps = function cleanupDeps () {
- var this$1 = this;
+ // merge component management hooks onto the placeholder node
+ mergeHooks(data);
- var i = this.deps.length;
- while (i--) {
- var dep = this$1.deps[i];
- if (!this$1.newDepIds.has(dep.id)) {
- dep.removeSub(this$1);
+ // return a placeholder vnode
+ var name = Ctor.options.name || tag;
+ var vnode = new VNode(
+ ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
+ data, undefined, undefined, undefined, context,
+ { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
+ );
+ return vnode
+}
+
+function createFunctionalComponent (
+ Ctor,
+ propsData,
+ data,
+ context,
+ children
+) {
+ var props = {};
+ var propOptions = Ctor.options.props;
+ if (propOptions) {
+ for (var key in propOptions) {
+ props[key] = validateProp(key, propOptions, propsData);
}
}
- var tmp = this.depIds;
- this.depIds = this.newDepIds;
- this.newDepIds = tmp;
- this.newDepIds.clear();
- tmp = this.deps;
- this.deps = this.newDeps;
- this.newDeps = tmp;
- this.newDeps.length = 0;
-};
+ // ensure the createElement function in functional components
+ // gets a unique context - this is necessary for correct named slot check
+ var _context = Object.create(context);
+ var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
+ var vnode = Ctor.options.render.call(null, h, {
+ props: props,
+ data: data,
+ parent: context,
+ children: children,
+ slots: function () { return resolveSlots(children, context); }
+ });
+ if (vnode instanceof VNode) {
+ vnode.functionalContext = context;
+ if (data.slot) {
+ (vnode.data || (vnode.data = {})).slot = data.slot;
+ }
+ }
+ return vnode
+}
-/**
- * Subscriber interface.
- * Will be called when a dependency changes.
- */
-Watcher.prototype.update = function update () {
- /* istanbul ignore else */
- if (this.lazy) {
- this.dirty = true;
- } else if (this.sync) {
- this.run();
- } else {
- queueWatcher(this);
+function createComponentInstanceForVnode (
+ vnode, // we know it's MountedComponentVNode but flow doesn't
+ parent, // activeInstance in lifecycle state
+ parentElm,
+ refElm
+) {
+ var vnodeComponentOptions = vnode.componentOptions;
+ var options = {
+ _isComponent: true,
+ parent: parent,
+ propsData: vnodeComponentOptions.propsData,
+ _componentTag: vnodeComponentOptions.tag,
+ _parentVnode: vnode,
+ _parentListeners: vnodeComponentOptions.listeners,
+ _renderChildren: vnodeComponentOptions.children,
+ _parentElm: parentElm || null,
+ _refElm: refElm || null
+ };
+ // check inline-template render functions
+ var inlineTemplate = vnode.data.inlineTemplate;
+ if (inlineTemplate) {
+ options.render = inlineTemplate.render;
+ options.staticRenderFns = inlineTemplate.staticRenderFns;
}
-};
+ return new vnodeComponentOptions.Ctor(options)
+}
-/**
- * Scheduler job interface.
- * Will be called by the scheduler.
- */
-Watcher.prototype.run = function run () {
- if (this.active) {
- var value = this.get();
- if (
- value !== this.value ||
- // Deep watchers and watchers on Object/Arrays should fire even
- // when the value is the same, because the value may
- // have mutated.
- isObject(value) ||
- this.deep
- ) {
- // set new value
- var oldValue = this.value;
- this.value = value;
- if (this.user) {
- try {
- this.cb.call(this.vm, value, oldValue);
- } catch (e) {
- /* istanbul ignore else */
- if (config.errorHandler) {
- config.errorHandler.call(null, e, this.vm);
- } else {
- "development" !== 'production' && warn(
- ("Error in watcher \"" + (this.expression) + "\""),
- this.vm
- );
- throw e
- }
- }
- } else {
- this.cb.call(this.vm, value, oldValue);
- }
- }
+function init$1 (
+ vnode,
+ hydrating,
+ parentElm,
+ refElm
+) {
+ if (!vnode.child || vnode.child._isDestroyed) {
+ var child = vnode.child = createComponentInstanceForVnode(
+ vnode,
+ activeInstance,
+ parentElm,
+ refElm
+ );
+ child.$mount(hydrating ? vnode.elm : undefined, hydrating);
+ } else if (vnode.data.keepAlive) {
+ // kept-alive components, treat as a patch
+ var mountedNode = vnode; // work around flow
+ prepatch(mountedNode, mountedNode);
}
-};
+}
-/**
- * Evaluate the value of the watcher.
- * This only gets called for lazy watchers.
- */
-Watcher.prototype.evaluate = function evaluate () {
- this.value = this.get();
- this.dirty = false;
-};
+function prepatch (
+ oldVnode,
+ vnode
+) {
+ var options = vnode.componentOptions;
+ var child = vnode.child = oldVnode.child;
+ child._updateFromParent(
+ options.propsData, // updated props
+ options.listeners, // updated listeners
+ vnode, // new parent vnode
+ options.children // new children
+ );
+}
-/**
- * Depend on all deps collected by this watcher.
- */
-Watcher.prototype.depend = function depend () {
- var this$1 = this;
+function insert (vnode) {
+ if (!vnode.child._isMounted) {
+ vnode.child._isMounted = true;
+ callHook(vnode.child, 'mounted');
+ }
+ if (vnode.data.keepAlive) {
+ vnode.child._inactive = false;
+ callHook(vnode.child, 'activated');
+ }
+}
- var i = this.deps.length;
- while (i--) {
- this$1.deps[i].depend();
+function destroy$1 (vnode) {
+ if (!vnode.child._isDestroyed) {
+ if (!vnode.data.keepAlive) {
+ vnode.child.$destroy();
+ } else {
+ vnode.child._inactive = true;
+ callHook(vnode.child, 'deactivated');
+ }
}
-};
+}
-/**
- * Remove self from all dependencies' subscriber list.
- */
-Watcher.prototype.teardown = function teardown () {
- var this$1 = this;
+function resolveAsyncComponent (
+ factory,
+ baseCtor,
+ cb
+) {
+ if (factory.requested) {
+ // pool callbacks
+ factory.pendingCallbacks.push(cb);
+ } else {
+ factory.requested = true;
+ var cbs = factory.pendingCallbacks = [cb];
+ var sync = true;
- if (this.active) {
- // remove self from vm's watcher list
- // this is a somewhat expensive operation so we skip it
- // if the vm is being destroyed.
- if (!this.vm._isBeingDestroyed) {
- remove(this.vm._watchers, this);
- }
- var i = this.deps.length;
- while (i--) {
- this$1.deps[i].removeSub(this$1);
+ var resolve = function (res) {
+ if (isObject(res)) {
+ res = baseCtor.extend(res);
+ }
+ // cache resolved
+ factory.resolved = res;
+ // invoke callbacks only if this is not a synchronous resolve
+ // (async resolves are shimmed as synchronous during SSR)
+ if (!sync) {
+ for (var i = 0, l = cbs.length; i < l; i++) {
+ cbs[i](res);
+ }
+ }
+ };
+
+ var reject = function (reason) {
+ "development" !== 'production' && warn(
+ "Failed to resolve async component: " + (String(factory)) +
+ (reason ? ("\nReason: " + reason) : '')
+ );
+ };
+
+ var res = factory(resolve, reject);
+
+ // handle promise
+ if (res && typeof res.then === 'function' && !factory.resolved) {
+ res.then(resolve, reject);
}
- this.active = false;
- }
-};
-/**
- * Recursively traverse an object to evoke all converted
- * getters, so that every nested property inside the object
- * is collected as a "deep" dependency.
- */
-var seenObjects = new _Set();
-function traverse (val) {
- seenObjects.clear();
- _traverse(val, seenObjects);
+ sync = false;
+ // return in case resolved synchronously
+ return factory.resolved
+ }
}
-function _traverse (val, seen) {
- var i, keys;
- var isA = Array.isArray(val);
- if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
+function extractProps (data, Ctor) {
+ // we are only extracting raw values here.
+ // validation and default values are handled in the child
+ // component itself.
+ var propOptions = Ctor.options.props;
+ if (!propOptions) {
return
}
- if (val.__ob__) {
- var depId = val.__ob__.dep.id;
- if (seen.has(depId)) {
- return
+ var res = {};
+ var attrs = data.attrs;
+ var props = data.props;
+ var domProps = data.domProps;
+ if (attrs || props || domProps) {
+ for (var key in propOptions) {
+ var altKey = hyphenate(key);
+ checkProp(res, props, key, altKey, true) ||
+ checkProp(res, attrs, key, altKey) ||
+ checkProp(res, domProps, key, altKey);
}
- seen.add(depId);
- }
- if (isA) {
- i = val.length;
- while (i--) { _traverse(val[i], seen); }
- } else {
- keys = Object.keys(val);
- i = keys.length;
- while (i--) { _traverse(val[keys[i]], seen); }
- }
-}
-
-/* */
-
-function initState (vm) {
- vm._watchers = [];
- var opts = vm.$options;
- if (opts.props) { initProps(vm, opts.props); }
- if (opts.methods) { initMethods(vm, opts.methods); }
- if (opts.data) {
- initData(vm);
- } else {
- observe(vm._data = {}, true /* asRootData */);
}
- if (opts.computed) { initComputed(vm, opts.computed); }
- if (opts.watch) { initWatch(vm, opts.watch); }
+ return res
}
-var isReservedProp = { key: 1, ref: 1, slot: 1 };
-
-function initProps (vm, props) {
- var propsData = vm.$options.propsData || {};
- var keys = vm.$options._propKeys = Object.keys(props);
- var isRoot = !vm.$parent;
- // root instance props should be converted
- observerState.shouldConvert = isRoot;
- var loop = function ( i ) {
- var key = keys[i];
- /* istanbul ignore else */
- {
- if (isReservedProp[key]) {
- warn(
- ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
- vm
- );
+function checkProp (
+ res,
+ hash,
+ key,
+ altKey,
+ preserve
+) {
+ if (hash) {
+ if (hasOwn(hash, key)) {
+ res[key] = hash[key];
+ if (!preserve) {
+ delete hash[key];
+ }
+ return true
+ } else if (hasOwn(hash, altKey)) {
+ res[key] = hash[altKey];
+ if (!preserve) {
+ delete hash[altKey];
}
- defineReactive$$1(vm, key, validateProp(key, props, propsData, vm), function () {
- if (vm.$parent && !observerState.isSettingProps) {
- warn(
- "Avoid mutating a prop directly since the value will be " +
- "overwritten whenever the parent component re-renders. " +
- "Instead, use a data or computed property based on the prop's " +
- "value. Prop being mutated: \"" + key + "\"",
- vm
- );
- }
- });
+ return true
}
- };
-
- for (var i = 0; i < keys.length; i++) { loop( i ); }
- observerState.shouldConvert = true;
+ }
+ return false
}
-function initData (vm) {
- var data = vm.$options.data;
- data = vm._data = typeof data === 'function'
- ? data.call(vm)
- : data || {};
- if (!isPlainObject(data)) {
- data = {};
- "development" !== 'production' && warn(
- 'data functions should return an object:\n' +
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
- vm
- );
+function mergeHooks (data) {
+ if (!data.hook) {
+ data.hook = {};
}
- // proxy data on instance
- var keys = Object.keys(data);
- var props = vm.$options.props;
- var i = keys.length;
- while (i--) {
- if (props && hasOwn(props, keys[i])) {
- "development" !== 'production' && warn(
- "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
- "Use prop default value instead.",
- vm
- );
- } else {
- proxy(vm, keys[i]);
- }
+ for (var i = 0; i < hooksToMerge.length; i++) {
+ var key = hooksToMerge[i];
+ var fromParent = data.hook[key];
+ var ours = hooks[key];
+ data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
}
- // observe data
- observe(data, true /* asRootData */);
}
-var computedSharedDefinition = {
- enumerable: true,
- configurable: true,
- get: noop,
- set: noop
-};
-
-function initComputed (vm, computed) {
- for (var key in computed) {
- /* istanbul ignore if */
- if ("development" !== 'production' && key in vm) {
- warn(
- "existing instance property \"" + key + "\" will be " +
- "overwritten by a computed property with the same name.",
- vm
- );
- }
- var userDef = computed[key];
- if (typeof userDef === 'function') {
- computedSharedDefinition.get = makeComputedGetter(userDef, vm);
- computedSharedDefinition.set = noop;
- } else {
- computedSharedDefinition.get = userDef.get
- ? userDef.cache !== false
- ? makeComputedGetter(userDef.get, vm)
- : bind(userDef.get, vm)
- : noop;
- computedSharedDefinition.set = userDef.set
- ? bind(userDef.set, vm)
- : noop;
- }
- Object.defineProperty(vm, key, computedSharedDefinition);
+function mergeHook$1 (one, two) {
+ return function (a, b, c, d) {
+ one(a, b, c, d);
+ two(a, b, c, d);
}
}
-function makeComputedGetter (getter, owner) {
- var watcher = new Watcher(owner, getter, noop, {
- lazy: true
- });
- return function computedGetter () {
- if (watcher.dirty) {
- watcher.evaluate();
- }
- if (Dep.target) {
- watcher.depend();
+/* */
+
+function mergeVNodeHook (def, hookKey, hook, key) {
+ key = key + hookKey;
+ var injectedHash = def.__injected || (def.__injected = {});
+ if (!injectedHash[key]) {
+ injectedHash[key] = true;
+ var oldHook = def[hookKey];
+ if (oldHook) {
+ def[hookKey] = function () {
+ oldHook.apply(this, arguments);
+ hook.apply(this, arguments);
+ };
+ } else {
+ def[hookKey] = hook;
}
- return watcher.value
}
}
-function initMethods (vm, methods) {
- for (var key in methods) {
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
- if ("development" !== 'production' && methods[key] == null) {
- warn(
- "method \"" + key + "\" has an undefined value in the component definition. " +
- "Did you reference the function correctly?",
+/* */
+
+function updateListeners (
+ on,
+ oldOn,
+ add,
+ remove$$1,
+ vm
+) {
+ var name, cur, old, fn, event, capture, once;
+ for (name in on) {
+ cur = on[name];
+ old = oldOn[name];
+ if (!cur) {
+ "development" !== 'production' && warn(
+ "Invalid handler for event \"" + name + "\": got " + String(cur),
vm
);
+ } else if (!old) {
+ once = name.charAt(0) === '~'; // Prefixed last, checked first
+ event = once ? name.slice(1) : name;
+ capture = event.charAt(0) === '!';
+ event = capture ? event.slice(1) : event;
+ if (Array.isArray(cur)) {
+ add(event, (cur.invoker = arrInvoker(cur)), once, capture);
+ } else {
+ if (!cur.invoker) {
+ fn = cur;
+ cur = on[name] = {};
+ cur.fn = fn;
+ cur.invoker = fnInvoker(cur);
+ }
+ add(event, cur.invoker, once, capture);
+ }
+ } else if (cur !== old) {
+ if (Array.isArray(old)) {
+ old.length = cur.length;
+ for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
+ on[name] = old;
+ } else {
+ old.fn = cur;
+ on[name] = old;
+ }
+ }
+ }
+ for (name in oldOn) {
+ if (!on[name]) {
+ once = name.charAt(0) === '~'; // Prefixed last, checked first
+ event = once ? name.slice(1) : name;
+ capture = event.charAt(0) === '!';
+ event = capture ? event.slice(1) : event;
+ remove$$1(event, oldOn[name].invoker, capture);
}
}
}
-function initWatch (vm, watch) {
- for (var key in watch) {
- var handler = watch[key];
- if (Array.isArray(handler)) {
- for (var i = 0; i < handler.length; i++) {
- createWatcher(vm, key, handler[i]);
- }
- } else {
- createWatcher(vm, key, handler);
+function arrInvoker (arr) {
+ return function (ev) {
+ var arguments$1 = arguments;
+
+ var single = arguments.length === 1;
+ for (var i = 0; i < arr.length; i++) {
+ single ? arr[i](ev) : arr[i].apply(null, arguments$1);
}
}
}
-function createWatcher (vm, key, handler) {
- var options;
- if (isPlainObject(handler)) {
- options = handler;
- handler = handler.handler;
- }
- if (typeof handler === 'string') {
- handler = vm[handler];
+function fnInvoker (o) {
+ return function (ev) {
+ var single = arguments.length === 1;
+ single ? o.fn(ev) : o.fn.apply(null, arguments);
}
- vm.$watch(key, handler, options);
}
-function stateMixin (Vue) {
- // flow somehow has problems with directly declared definition object
- // when using Object.defineProperty, so we have to procedurally build up
- // the object here.
- var dataDef = {};
- dataDef.get = function () {
- return this._data
- };
- {
- dataDef.set = function (newData) {
- warn(
- 'Avoid replacing instance root $data. ' +
- 'Use nested data properties instead.',
- this
- );
- };
- }
- Object.defineProperty(Vue.prototype, '$data', dataDef);
+/* */
- Vue.prototype.$set = set$1;
- Vue.prototype.$delete = del;
+// The template compiler attempts to minimize the need for normalization by
+// statically analyzing the template at compile time.
+//
+// For plain HTML markup, normalization can be completely skipped because the
+// generated render function is guaranteed to return Array<VNode>. There are
+// two cases where extra normalization is needed:
- Vue.prototype.$watch = function (
- expOrFn,
- cb,
- options
- ) {
- var vm = this;
- options = options || {};
- options.user = true;
- var watcher = new Watcher(vm, expOrFn, cb, options);
- if (options.immediate) {
- cb.call(vm, watcher.value);
- }
- return function unwatchFn () {
- watcher.teardown();
+// 1. When the children contains components - because a functional component
+// may return an Array instead of a single root. In this case, just a simple
+// nomralization is needed - if any child is an Array, we flatten the whole
+// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
+// because functional components already normalize their own children.
+function simpleNormalizeChildren (children) {
+ for (var i = 0; i < children.length; i++) {
+ if (Array.isArray(children[i])) {
+ return Array.prototype.concat.apply([], children)
}
- };
+ }
+ return children
}
-function proxy (vm, key) {
- if (!isReserved(key)) {
- Object.defineProperty(vm, key, {
- configurable: true,
- enumerable: true,
- get: function proxyGetter () {
- return vm._data[key]
- },
- set: function proxySetter (val) {
- vm._data[key] = val;
+// 2. When the children contains constrcuts that always generated nested Arrays,
+// e.g. <template>, <slot>, v-for, or when the children is provided by user
+// with hand-written render functions / JSX. In such cases a full normalization
+// is needed to cater to all possible types of children values.
+function normalizeChildren (children) {
+ return isPrimitive(children)
+ ? [createTextVNode(children)]
+ : Array.isArray(children)
+ ? normalizeArrayChildren(children)
+ : undefined
+}
+
+function normalizeArrayChildren (children, nestedIndex) {
+ var res = [];
+ var i, c, last;
+ for (i = 0; i < children.length; i++) {
+ c = children[i];
+ if (c == null || typeof c === 'boolean') { continue }
+ last = res[res.length - 1];
+ // nested
+ if (Array.isArray(c)) {
+ res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
+ } else if (isPrimitive(c)) {
+ if (last && last.text) {
+ last.text += String(c);
+ } else if (c !== '') {
+ // convert primitive to vnode
+ res.push(createTextVNode(c));
}
- });
+ } else {
+ if (c.text && last && last.text) {
+ res[res.length - 1] = createTextVNode(last.text + c.text);
+ } else {
+ // default key for nested array children (likely generated by v-for)
+ if (c.tag && c.key == null && nestedIndex != null) {
+ c.key = "__vlist" + nestedIndex + "_" + i + "__";
+ }
+ res.push(c);
+ }
+ }
}
+ return res
}
/* */
-var VNode = function VNode (
+function getFirstComponentChild (children) {
+ return children && children.filter(function (c) { return c && c.componentOptions; })[0]
+}
+
+/* */
+
+var SIMPLE_NORMALIZE = 1;
+var ALWAYS_NORMALIZE = 2;
+
+// wrapper function for providing a more flexible interface
+// without getting yelled at by flow
+function createElement (
+ context,
tag,
data,
children,
- text,
- elm,
- context,
- componentOptions
+ normalizationType,
+ alwaysNormalize
) {
- this.tag = tag;
- this.data = data;
- this.children = children;
- this.text = text;
- this.elm = elm;
- this.ns = undefined;
- this.context = context;
- this.functionalContext = undefined;
- this.key = data && data.key;
- this.componentOptions = componentOptions;
- this.child = undefined;
- this.parent = undefined;
- this.raw = false;
- this.isStatic = false;
- this.isRootInsert = true;
- this.isComment = false;
- this.isCloned = false;
- this.isOnce = false;
-};
-
-var createEmptyVNode = function () {
- var node = new VNode();
- node.text = '';
- node.isComment = true;
- return node
-};
-
-function createTextVNode (val) {
- return new VNode(undefined, undefined, undefined, String(val))
+ if (Array.isArray(data) || isPrimitive(data)) {
+ normalizationType = children;
+ children = data;
+ data = undefined;
+ }
+ if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
+ return _createElement(context, tag, data, children, normalizationType)
}
-// optimized shallow clone
-// used for static nodes and slot nodes because they may be reused across
-// multiple renders, cloning them avoids errors when DOM manipulations rely
-// on their elm reference.
-function cloneVNode (vnode) {
- var cloned = new VNode(
- vnode.tag,
- vnode.data,
- vnode.children,
- vnode.text,
- vnode.elm,
- vnode.context,
- vnode.componentOptions
- );
- cloned.ns = vnode.ns;
- cloned.isStatic = vnode.isStatic;
- cloned.key = vnode.key;
- cloned.isCloned = true;
- return cloned
+function _createElement (
+ context,
+ tag,
+ data,
+ children,
+ normalizationType
+) {
+ if (data && data.__ob__) {
+ "development" !== 'production' && warn(
+ "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
+ 'Always create fresh vnode data objects in each render!',
+ context
+ );
+ return createEmptyVNode()
+ }
+ if (!tag) {
+ // in case of component :is set to falsy value
+ return createEmptyVNode()
+ }
+ // support single function children as default scoped slot
+ if (Array.isArray(children) &&
+ typeof children[0] === 'function') {
+ data = data || {};
+ data.scopedSlots = { default: children[0] };
+ children.length = 0;
+ }
+ if (normalizationType === ALWAYS_NORMALIZE) {
+ children = normalizeChildren(children);
+ } else if (normalizationType === SIMPLE_NORMALIZE) {
+ children = simpleNormalizeChildren(children);
+ }
+ var vnode, ns;
+ if (typeof tag === 'string') {
+ var Ctor;
+ ns = config.getTagNamespace(tag);
+ if (config.isReservedTag(tag)) {
+ // platform built-in elements
+ vnode = new VNode(
+ config.parsePlatformTagName(tag), data, children,
+ undefined, undefined, context
+ );
+ } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
+ // component
+ vnode = createComponent(Ctor, data, context, children, tag);
+ } else {
+ // unknown or unlisted namespaced elements
+ // check at runtime because it may get assigned a namespace when its
+ // parent normalizes children
+ vnode = new VNode(
+ tag, data, children,
+ undefined, undefined, context
+ );
+ }
+ } else {
+ // direct component options / constructor
+ vnode = createComponent(tag, data, context, children);
+ }
+ if (vnode) {
+ if (ns) { applyNS(vnode, ns); }
+ return vnode
+ } else {
+ return createEmptyVNode()
+ }
}
-function cloneVNodes (vnodes) {
- var res = new Array(vnodes.length);
- for (var i = 0; i < vnodes.length; i++) {
- res[i] = cloneVNode(vnodes[i]);
+function applyNS (vnode, ns) {
+ vnode.ns = ns;
+ if (vnode.tag === 'foreignObject') {
+ // use default namespace inside foreignObject
+ return
+ }
+ if (vnode.children) {
+ for (var i = 0, l = vnode.children.length; i < l; i++) {
+ var child = vnode.children[i];
+ if (child.tag && !child.ns) {
+ applyNS(child, ns);
+ }
+ }
}
- return res
}
/* */
-function mergeVNodeHook (def, hookKey, hook, key) {
- key = key + hookKey;
- var injectedHash = def.__injected || (def.__injected = {});
- if (!injectedHash[key]) {
- injectedHash[key] = true;
- var oldHook = def[hookKey];
- if (oldHook) {
- def[hookKey] = function () {
- oldHook.apply(this, arguments);
- hook.apply(this, arguments);
- };
- } else {
- def[hookKey] = hook;
+function initRender (vm) {
+ vm.$vnode = null; // the placeholder node in parent tree
+ vm._vnode = null; // the root of the child tree
+ vm._staticTrees = null;
+ var parentVnode = vm.$options._parentVnode;
+ var renderContext = parentVnode && parentVnode.context;
+ vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
+ vm.$scopedSlots = {};
+ // bind the createElement fn to this instance
+ // so that we get proper render context inside it.
+ // args order: tag, data, children, normalizationType, alwaysNormalize
+ // internal version is used by render functions compiled from templates
+ vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
+ // normalization is always applied for the public version, used in
+ // user-written render functions.
+ vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
+ if (vm.$options.el) {
+ vm.$mount(vm.$options.el);
+ }
+}
+
+function renderMixin (Vue) {
+ Vue.prototype.$nextTick = function (fn) {
+ return nextTick(fn, this)
+ };
+
+ Vue.prototype._render = function () {
+ var vm = this;
+ var ref = vm.$options;
+ var render = ref.render;
+ var staticRenderFns = ref.staticRenderFns;
+ var _parentVnode = ref._parentVnode;
+
+ if (vm._isMounted) {
+ // clone slot nodes on re-renders
+ for (var key in vm.$slots) {
+ vm.$slots[key] = cloneVNodes(vm.$slots[key]);
+ }
}
- }
-}
-/* */
+ if (_parentVnode && _parentVnode.data.scopedSlots) {
+ vm.$scopedSlots = _parentVnode.data.scopedSlots;
+ }
-function updateListeners (
- on,
- oldOn,
- add,
- remove$$1,
- vm
-) {
- var name, cur, old, fn, event, capture, once;
- for (name in on) {
- cur = on[name];
- old = oldOn[name];
- if (!cur) {
- "development" !== 'production' && warn(
- "Invalid handler for event \"" + name + "\": got " + String(cur),
- vm
- );
- } else if (!old) {
- once = name.charAt(0) === '~'; // Prefixed last, checked first
- event = once ? name.slice(1) : name;
- capture = event.charAt(0) === '!';
- event = capture ? event.slice(1) : event;
- if (Array.isArray(cur)) {
- add(event, (cur.invoker = arrInvoker(cur)), once, capture);
+ if (staticRenderFns && !vm._staticTrees) {
+ vm._staticTrees = [];
+ }
+ // set parent vnode. this allows render functions to have access
+ // to the data on the placeholder node.
+ vm.$vnode = _parentVnode;
+ // render self
+ var vnode;
+ try {
+ vnode = render.call(vm._renderProxy, vm.$createElement);
+ } catch (e) {
+ /* istanbul ignore else */
+ if (config.errorHandler) {
+ config.errorHandler.call(null, e, vm);
} else {
- if (!cur.invoker) {
- fn = cur;
- cur = on[name] = {};
- cur.fn = fn;
- cur.invoker = fnInvoker(cur);
+ {
+ warn(("Error when rendering " + (formatComponentName(vm)) + ":"));
}
- add(event, cur.invoker, once, capture);
+ throw e
}
- } else if (cur !== old) {
- if (Array.isArray(old)) {
- old.length = cur.length;
- for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
- on[name] = old;
- } else {
- old.fn = cur;
- on[name] = old;
+ // return previous vnode to prevent render error causing blank component
+ vnode = vm._vnode;
+ }
+ // return empty vnode in case the render function errored out
+ if (!(vnode instanceof VNode)) {
+ if ("development" !== 'production' && Array.isArray(vnode)) {
+ warn(
+ 'Multiple root nodes returned from render function. Render function ' +
+ 'should return a single root node.',
+ vm
+ );
}
+ vnode = createEmptyVNode();
}
- }
- for (name in oldOn) {
- if (!on[name]) {
- once = name.charAt(0) === '~'; // Prefixed last, checked first
- event = once ? name.slice(1) : name;
- capture = event.charAt(0) === '!';
- event = capture ? event.slice(1) : event;
- remove$$1(event, oldOn[name].invoker, capture);
+ // set parent
+ vnode.parent = _parentVnode;
+ return vnode
+ };
+
+ // toString for mustaches
+ Vue.prototype._s = _toString;
+ // convert text to vnode
+ Vue.prototype._v = createTextVNode;
+ // number conversion
+ Vue.prototype._n = toNumber;
+ // empty vnode
+ Vue.prototype._e = createEmptyVNode;
+ // loose equal
+ Vue.prototype._q = looseEqual;
+ // loose indexOf
+ Vue.prototype._i = looseIndexOf;
+
+ // render static tree by index
+ Vue.prototype._m = function renderStatic (
+ index,
+ isInFor
+ ) {
+ var tree = this._staticTrees[index];
+ // if has already-rendered static tree and not inside v-for,
+ // we can reuse the same tree by doing a shallow clone.
+ if (tree && !isInFor) {
+ return Array.isArray(tree)
+ ? cloneVNodes(tree)
+ : cloneVNode(tree)
}
- }
-}
+ // otherwise, render a fresh tree.
+ tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
+ markStatic(tree, ("__static__" + index), false);
+ return tree
+ };
-function arrInvoker (arr) {
- return function (ev) {
- var arguments$1 = arguments;
+ // mark node as static (v-once)
+ Vue.prototype._o = function markOnce (
+ tree,
+ index,
+ key
+ ) {
+ markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
+ return tree
+ };
- var single = arguments.length === 1;
- for (var i = 0; i < arr.length; i++) {
- single ? arr[i](ev) : arr[i].apply(null, arguments$1);
+ function markStatic (tree, key, isOnce) {
+ if (Array.isArray(tree)) {
+ for (var i = 0; i < tree.length; i++) {
+ if (tree[i] && typeof tree[i] !== 'string') {
+ markStaticNode(tree[i], (key + "_" + i), isOnce);
+ }
+ }
+ } else {
+ markStaticNode(tree, key, isOnce);
}
}
-}
-function fnInvoker (o) {
- return function (ev) {
- var single = arguments.length === 1;
- single ? o.fn(ev) : o.fn.apply(null, arguments);
+ function markStaticNode (node, key, isOnce) {
+ node.isStatic = true;
+ node.key = key;
+ node.isOnce = isOnce;
}
-}
-/* */
+ // filter resolution helper
+ Vue.prototype._f = function resolveFilter (id) {
+ return resolveAsset(this.$options, 'filters', id, true) || identity
+ };
-// The template compiler attempts to minimize the need for normalization by
-// statically analyzing the template at compile time.
-//
-// For plain HTML markup, normalization can be completely skipped because the
-// generated render function is guaranteed to return Array<VNode>. There are
-// two cases where extra normalization is needed:
+ // render v-for
+ Vue.prototype._l = function renderList (
+ val,
+ render
+ ) {
+ var ret, i, l, keys, key;
+ if (Array.isArray(val) || typeof val === 'string') {
+ ret = new Array(val.length);
+ for (i = 0, l = val.length; i < l; i++) {
+ ret[i] = render(val[i], i);
+ }
+ } else if (typeof val === 'number') {
+ ret = new Array(val);
+ for (i = 0; i < val; i++) {
+ ret[i] = render(i + 1, i);
+ }
+ } else if (isObject(val)) {
+ keys = Object.keys(val);
+ ret = new Array(keys.length);
+ for (i = 0, l = keys.length; i < l; i++) {
+ key = keys[i];
+ ret[i] = render(val[key], key, i);
+ }
+ }
+ return ret
+ };
-// 1. When the children contains components - because a functional component
-// may return an Array instead of a single root. In this case, just a simple
-// nomralization is needed - if any child is an Array, we flatten the whole
-// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
-// because functional components already normalize their own children.
-function simpleNormalizeChildren (children) {
- for (var i = 0; i < children.length; i++) {
- if (Array.isArray(children[i])) {
- return Array.prototype.concat.apply([], children)
+ // renderSlot
+ Vue.prototype._t = function (
+ name,
+ fallback,
+ props,
+ bindObject
+ ) {
+ var scopedSlotFn = this.$scopedSlots[name];
+ if (scopedSlotFn) { // scoped slot
+ props = props || {};
+ if (bindObject) {
+ extend(props, bindObject);
+ }
+ return scopedSlotFn(props) || fallback
+ } else {
+ var slotNodes = this.$slots[name];
+ // warn duplicate slot usage
+ if (slotNodes && "development" !== 'production') {
+ slotNodes._rendered && warn(
+ "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
+ "- this will likely cause render errors.",
+ this
+ );
+ slotNodes._rendered = true;
+ }
+ return slotNodes || fallback
+ }
+ };
+
+ // apply v-bind object
+ Vue.prototype._b = function bindProps (
+ data,
+ tag,
+ value,
+ asProp
+ ) {
+ if (value) {
+ if (!isObject(value)) {
+ "development" !== 'production' && warn(
+ 'v-bind without argument expects an Object or Array value',
+ this
+ );
+ } else {
+ if (Array.isArray(value)) {
+ value = toObject(value);
+ }
+ for (var key in value) {
+ if (key === 'class' || key === 'style') {
+ data[key] = value[key];
+ } else {
+ var hash = asProp || config.mustUseProp(tag, key)
+ ? data.domProps || (data.domProps = {})
+ : data.attrs || (data.attrs = {});
+ hash[key] = value[key];
+ }
+ }
+ }
}
- }
- return children
-}
+ return data
+ };
-// 2. When the children contains constrcuts that always generated nested Arrays,
-// e.g. <template>, <slot>, v-for, or when the children is provided by user
-// with hand-written render functions / JSX. In such cases a full normalization
-// is needed to cater to all possible types of children values.
-function normalizeChildren (children) {
- return isPrimitive(children)
- ? [createTextVNode(children)]
- : Array.isArray(children)
- ? normalizeArrayChildren(children)
- : undefined
+ // check v-on keyCodes
+ Vue.prototype._k = function checkKeyCodes (
+ eventKeyCode,
+ key,
+ builtInAlias
+ ) {
+ var keyCodes = config.keyCodes[key] || builtInAlias;
+ if (Array.isArray(keyCodes)) {
+ return keyCodes.indexOf(eventKeyCode) === -1
+ } else {
+ return keyCodes !== eventKeyCode
+ }
+ };
}
-function normalizeArrayChildren (children, nestedIndex) {
- var res = [];
- var i, c, last;
- for (i = 0; i < children.length; i++) {
- c = children[i];
- if (c == null || typeof c === 'boolean') { continue }
- last = res[res.length - 1];
- // nested
- if (Array.isArray(c)) {
- res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
- } else if (isPrimitive(c)) {
- if (last && last.text) {
- last.text += String(c);
- } else if (c !== '') {
- // convert primitive to vnode
- res.push(createTextVNode(c));
- }
- } else {
- if (c.text && last && last.text) {
- res[res.length - 1] = createTextVNode(last.text + c.text);
+function resolveSlots (
+ children,
+ context
+) {
+ var slots = {};
+ if (!children) {
+ return slots
+ }
+ var defaultSlot = [];
+ var name, child;
+ for (var i = 0, l = children.length; i < l; i++) {
+ child = children[i];
+ // named slots should only be respected if the vnode was rendered in the
+ // same context.
+ if ((child.context === context || child.functionalContext === context) &&
+ child.data && (name = child.data.slot)) {
+ var slot = (slots[name] || (slots[name] = []));
+ if (child.tag === 'template') {
+ slot.push.apply(slot, child.children);
} else {
- // default key for nested array children (likely generated by v-for)
- if (c.tag && c.key == null && nestedIndex != null) {
- c.key = "__vlist" + nestedIndex + "_" + i + "__";
- }
- res.push(c);
+ slot.push(child);
}
+ } else {
+ defaultSlot.push(child);
}
}
- return res
-}
-
-/* */
-
-function getFirstComponentChild (children) {
- return children && children.filter(function (c) { return c && c.componentOptions; })[0]
+ // ignore single whitespace
+ if (defaultSlot.length && !(
+ defaultSlot.length === 1 &&
+ (defaultSlot[0].text === ' ' || defaultSlot[0].isComment)
+ )) {
+ slots.default = defaultSlot;
+ }
+ return slots
}
/* */
@@ -5990,9 +6137,8 @@ function lifecycleMixin (Vue) {
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
vm.$parent.$el = vm.$el;
}
- if (vm._isMounted) {
- callHook(vm, 'updated');
- }
+ // updated hook is called by the scheduler to ensure that children are
+ // updated in a parent's updated hook.
};
Vue.prototype._updateFromParent = function (
@@ -6071,742 +6217,606 @@ function lifecycleMixin (Vue) {
if (vm._data.__ob__) {
vm._data.__ob__.vmCount--;
}
- // call the last hook...
- vm._isDestroyed = true;
- callHook(vm, 'destroyed');
- // turn off all instance listeners.
- vm.$off();
- // remove __vue__ reference
- if (vm.$el) {
- vm.$el.__vue__ = null;
- }
- // invoke destroy hooks on current rendered tree
- vm.__patch__(vm._vnode, null);
- };
-}
-
-function callHook (vm, hook) {
- var handlers = vm.$options[hook];
- if (handlers) {
- for (var i = 0, j = handlers.length; i < j; i++) {
- handlers[i].call(vm);
- }
- }
- if (vm._hasHookEvent) {
- vm.$emit('hook:' + hook);
- }
-}
-
-/* */
-
-var hooks = { init: init$1, prepatch: prepatch, insert: insert, destroy: destroy$1 };
-var hooksToMerge = Object.keys(hooks);
-
-function createComponent (
- Ctor,
- data,
- context,
- children,
- tag
-) {
- if (!Ctor) {
- return
- }
-
- var baseCtor = context.$options._base;
- if (isObject(Ctor)) {
- Ctor = baseCtor.extend(Ctor);
- }
-
- if (typeof Ctor !== 'function') {
- {
- warn(("Invalid Component definition: " + (String(Ctor))), context);
- }
- return
- }
-
- // async component
- if (!Ctor.cid) {
- if (Ctor.resolved) {
- Ctor = Ctor.resolved;
- } else {
- Ctor = resolveAsyncComponent(Ctor, baseCtor, function () {
- // it's ok to queue this on every render because
- // $forceUpdate is buffered by the scheduler.
- context.$forceUpdate();
- });
- if (!Ctor) {
- // return nothing if this is indeed an async component
- // wait for the callback to trigger parent update.
- return
- }
- }
- }
-
- // resolve constructor options in case global mixins are applied after
- // component constructor creation
- resolveConstructorOptions(Ctor);
-
- data = data || {};
-
- // extract props
- var propsData = extractProps(data, Ctor);
-
- // functional component
- if (Ctor.options.functional) {
- return createFunctionalComponent(Ctor, propsData, data, context, children)
- }
-
- // extract listeners, since these needs to be treated as
- // child component listeners instead of DOM listeners
- var listeners = data.on;
- // replace with listeners with .native modifier
- data.on = data.nativeOn;
-
- if (Ctor.options.abstract) {
- // abstract components do not keep anything
- // other than props & listeners
- data = {};
- }
-
- // merge component management hooks onto the placeholder node
- mergeHooks(data);
-
- // return a placeholder vnode
- var name = Ctor.options.name || tag;
- var vnode = new VNode(
- ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
- data, undefined, undefined, undefined, context,
- { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
- );
- return vnode
-}
-
-function createFunctionalComponent (
- Ctor,
- propsData,
- data,
- context,
- children
-) {
- var props = {};
- var propOptions = Ctor.options.props;
- if (propOptions) {
- for (var key in propOptions) {
- props[key] = validateProp(key, propOptions, propsData);
- }
- }
- // ensure the createElement function in functional components
- // gets a unique context - this is necessary for correct named slot check
- var _context = Object.create(context);
- var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
- var vnode = Ctor.options.render.call(null, h, {
- props: props,
- data: data,
- parent: context,
- children: children,
- slots: function () { return resolveSlots(children, context); }
- });
- if (vnode instanceof VNode) {
- vnode.functionalContext = context;
- if (data.slot) {
- (vnode.data || (vnode.data = {})).slot = data.slot;
- }
- }
- return vnode
-}
-
-function createComponentInstanceForVnode (
- vnode, // we know it's MountedComponentVNode but flow doesn't
- parent, // activeInstance in lifecycle state
- parentElm,
- refElm
-) {
- var vnodeComponentOptions = vnode.componentOptions;
- var options = {
- _isComponent: true,
- parent: parent,
- propsData: vnodeComponentOptions.propsData,
- _componentTag: vnodeComponentOptions.tag,
- _parentVnode: vnode,
- _parentListeners: vnodeComponentOptions.listeners,
- _renderChildren: vnodeComponentOptions.children,
- _parentElm: parentElm || null,
- _refElm: refElm || null
+ // call the last hook...
+ vm._isDestroyed = true;
+ callHook(vm, 'destroyed');
+ // turn off all instance listeners.
+ vm.$off();
+ // remove __vue__ reference
+ if (vm.$el) {
+ vm.$el.__vue__ = null;
+ }
+ // invoke destroy hooks on current rendered tree
+ vm.__patch__(vm._vnode, null);
};
- // check inline-template render functions
- var inlineTemplate = vnode.data.inlineTemplate;
- if (inlineTemplate) {
- options.render = inlineTemplate.render;
- options.staticRenderFns = inlineTemplate.staticRenderFns;
- }
- return new vnodeComponentOptions.Ctor(options)
}
-function init$1 (
- vnode,
- hydrating,
- parentElm,
- refElm
-) {
- if (!vnode.child || vnode.child._isDestroyed) {
- var child = vnode.child = createComponentInstanceForVnode(
- vnode,
- activeInstance,
- parentElm,
- refElm
- );
- child.$mount(hydrating ? vnode.elm : undefined, hydrating);
- } else if (vnode.data.keepAlive) {
- // kept-alive components, treat as a patch
- var mountedNode = vnode; // work around flow
- prepatch(mountedNode, mountedNode);
+function callHook (vm, hook) {
+ var handlers = vm.$options[hook];
+ if (handlers) {
+ for (var i = 0, j = handlers.length; i < j; i++) {
+ handlers[i].call(vm);
+ }
+ }
+ if (vm._hasHookEvent) {
+ vm.$emit('hook:' + hook);
}
}
-function prepatch (
- oldVnode,
- vnode
-) {
- var options = vnode.componentOptions;
- var child = vnode.child = oldVnode.child;
- child._updateFromParent(
- options.propsData, // updated props
- options.listeners, // updated listeners
- vnode, // new parent vnode
- options.children // new children
- );
+/* */
+
+
+var queue = [];
+var has$1 = {};
+var circular = {};
+var waiting = false;
+var flushing = false;
+var index = 0;
+
+/**
+ * Reset the scheduler's state.
+ */
+function resetSchedulerState () {
+ queue.length = 0;
+ has$1 = {};
+ {
+ circular = {};
+ }
+ waiting = flushing = false;
}
-function insert (vnode) {
- if (!vnode.child._isMounted) {
- vnode.child._isMounted = true;
- callHook(vnode.child, 'mounted');
+/**
+ * Flush both queues and run the watchers.
+ */
+function flushSchedulerQueue () {
+ flushing = true;
+ var watcher, id, vm;
+
+ // Sort queue before flush.
+ // This ensures that:
+ // 1. Components are updated from parent to child. (because parent is always
+ // created before the child)
+ // 2. A component's user watchers are run before its render watcher (because
+ // user watchers are created before the render watcher)
+ // 3. If a component is destroyed during a parent component's watcher run,
+ // its watchers can be skipped.
+ queue.sort(function (a, b) { return a.id - b.id; });
+
+ // do not cache length because more watchers might be pushed
+ // as we run existing watchers
+ for (index = 0; index < queue.length; index++) {
+ watcher = queue[index];
+ id = watcher.id;
+ has$1[id] = null;
+ watcher.run();
+ // in dev build, check and stop circular updates.
+ if ("development" !== 'production' && has$1[id] != null) {
+ circular[id] = (circular[id] || 0) + 1;
+ if (circular[id] > config._maxUpdateCount) {
+ warn(
+ 'You may have an infinite update loop ' + (
+ watcher.user
+ ? ("in watcher with expression \"" + (watcher.expression) + "\"")
+ : "in a component render function."
+ ),
+ watcher.vm
+ );
+ break
+ }
+ }
}
- if (vnode.data.keepAlive) {
- vnode.child._inactive = false;
- callHook(vnode.child, 'activated');
+
+ // call updated hooks
+ index = queue.length;
+ while (index--) {
+ watcher = queue[index];
+ vm = watcher.vm;
+ if (vm._watcher === watcher && vm._isMounted) {
+ callHook(vm, 'updated');
+ }
+ }
+
+ // devtool hook
+ /* istanbul ignore if */
+ if (devtools && config.devtools) {
+ devtools.emit('flush');
}
+
+ resetSchedulerState();
}
-function destroy$1 (vnode) {
- if (!vnode.child._isDestroyed) {
- if (!vnode.data.keepAlive) {
- vnode.child.$destroy();
+/**
+ * Push a watcher into the watcher queue.
+ * Jobs with duplicate IDs will be skipped unless it's
+ * pushed when the queue is being flushed.
+ */
+function queueWatcher (watcher) {
+ var id = watcher.id;
+ if (has$1[id] == null) {
+ has$1[id] = true;
+ if (!flushing) {
+ queue.push(watcher);
} else {
- vnode.child._inactive = true;
- callHook(vnode.child, 'deactivated');
+ // if already flushing, splice the watcher based on its id
+ // if already past its id, it will be run next immediately.
+ var i = queue.length - 1;
+ while (i >= 0 && queue[i].id > watcher.id) {
+ i--;
+ }
+ queue.splice(Math.max(i, index) + 1, 0, watcher);
+ }
+ // queue the flush
+ if (!waiting) {
+ waiting = true;
+ nextTick(flushSchedulerQueue);
}
}
}
-function resolveAsyncComponent (
- factory,
- baseCtor,
- cb
-) {
- if (factory.requested) {
- // pool callbacks
- factory.pendingCallbacks.push(cb);
- } else {
- factory.requested = true;
- var cbs = factory.pendingCallbacks = [cb];
- var sync = true;
+/* */
- var resolve = function (res) {
- if (isObject(res)) {
- res = baseCtor.extend(res);
- }
- // cache resolved
- factory.resolved = res;
- // invoke callbacks only if this is not a synchronous resolve
- // (async resolves are shimmed as synchronous during SSR)
- if (!sync) {
- for (var i = 0, l = cbs.length; i < l; i++) {
- cbs[i](res);
- }
- }
- };
+var uid$2 = 0;
- var reject = function (reason) {
+/**
+ * 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.
+ */
+var Watcher = function Watcher (
+ vm,
+ expOrFn,
+ cb,
+ options
+) {
+ this.vm = vm;
+ vm._watchers.push(this);
+ // options
+ if (options) {
+ this.deep = !!options.deep;
+ this.user = !!options.user;
+ this.lazy = !!options.lazy;
+ this.sync = !!options.sync;
+ } else {
+ this.deep = this.user = this.lazy = this.sync = false;
+ }
+ this.cb = cb;
+ this.id = ++uid$2; // uid for batching
+ this.active = true;
+ this.dirty = this.lazy; // for lazy watchers
+ this.deps = [];
+ this.newDeps = [];
+ this.depIds = new _Set();
+ this.newDepIds = new _Set();
+ this.expression = expOrFn.toString();
+ // parse expression for getter
+ if (typeof expOrFn === 'function') {
+ this.getter = expOrFn;
+ } else {
+ this.getter = parsePath(expOrFn);
+ if (!this.getter) {
+ this.getter = function () {};
"development" !== 'production' && warn(
- "Failed to resolve async component: " + (String(factory)) +
- (reason ? ("\nReason: " + reason) : '')
+ "Failed watching path: \"" + expOrFn + "\" " +
+ 'Watcher only accepts simple dot-delimited paths. ' +
+ 'For full control, use a function instead.',
+ vm
);
- };
-
- var res = factory(resolve, reject);
-
- // handle promise
- if (res && typeof res.then === 'function' && !factory.resolved) {
- res.then(resolve, reject);
}
+ }
+ this.value = this.lazy
+ ? undefined
+ : this.get();
+};
- sync = false;
- // return in case resolved synchronously
- return factory.resolved
+/**
+ * Evaluate the getter, and re-collect dependencies.
+ */
+Watcher.prototype.get = function get () {
+ pushTarget(this);
+ var value = this.getter.call(this.vm, this.vm);
+ // "touch" every property so they are all tracked as
+ // dependencies for deep watching
+ if (this.deep) {
+ traverse(value);
}
-}
+ popTarget();
+ this.cleanupDeps();
+ return value
+};
-function extractProps (data, Ctor) {
- // we are only extracting raw values here.
- // validation and default values are handled in the child
- // component itself.
- var propOptions = Ctor.options.props;
- if (!propOptions) {
- return
- }
- var res = {};
- var attrs = data.attrs;
- var props = data.props;
- var domProps = data.domProps;
- if (attrs || props || domProps) {
- for (var key in propOptions) {
- var altKey = hyphenate(key);
- checkProp(res, props, key, altKey, true) ||
- checkProp(res, attrs, key, altKey) ||
- checkProp(res, domProps, key, altKey);
+/**
+ * Add a dependency to this directive.
+ */
+Watcher.prototype.addDep = function addDep (dep) {
+ var id = dep.id;
+ if (!this.newDepIds.has(id)) {
+ this.newDepIds.add(id);
+ this.newDeps.push(dep);
+ if (!this.depIds.has(id)) {
+ dep.addSub(this);
}
}
- return res
-}
+};
-function checkProp (
- res,
- hash,
- key,
- altKey,
- preserve
-) {
- if (hash) {
- if (hasOwn(hash, key)) {
- res[key] = hash[key];
- if (!preserve) {
- delete hash[key];
- }
- return true
- } else if (hasOwn(hash, altKey)) {
- res[key] = hash[altKey];
- if (!preserve) {
- delete hash[altKey];
- }
- return true
+/**
+ * Clean up for dependency collection.
+ */
+Watcher.prototype.cleanupDeps = function cleanupDeps () {
+ var this$1 = this;
+
+ var i = this.deps.length;
+ while (i--) {
+ var dep = this$1.deps[i];
+ if (!this$1.newDepIds.has(dep.id)) {
+ dep.removeSub(this$1);
}
}
- return false
-}
+ var tmp = this.depIds;
+ this.depIds = this.newDepIds;
+ this.newDepIds = tmp;
+ this.newDepIds.clear();
+ tmp = this.deps;
+ this.deps = this.newDeps;
+ this.newDeps = tmp;
+ this.newDeps.length = 0;
+};
-function mergeHooks (data) {
- if (!data.hook) {
- data.hook = {};
- }
- for (var i = 0; i < hooksToMerge.length; i++) {
- var key = hooksToMerge[i];
- var fromParent = data.hook[key];
- var ours = hooks[key];
- data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
+/**
+ * Subscriber interface.
+ * Will be called when a dependency changes.
+ */
+Watcher.prototype.update = function update () {
+ /* istanbul ignore else */
+ if (this.lazy) {
+ this.dirty = true;
+ } else if (this.sync) {
+ this.run();
+ } else {
+ queueWatcher(this);
}
-}
+};
-function mergeHook$1 (one, two) {
- return function (a, b, c, d) {
- one(a, b, c, d);
- two(a, b, c, d);
+/**
+ * Scheduler job interface.
+ * Will be called by the scheduler.
+ */
+Watcher.prototype.run = function run () {
+ if (this.active) {
+ var value = this.get();
+ if (
+ value !== this.value ||
+ // Deep watchers and watchers on Object/Arrays should fire even
+ // when the value is the same, because the value may
+ // have mutated.
+ isObject(value) ||
+ this.deep
+ ) {
+ // set new value
+ var oldValue = this.value;
+ this.value = value;
+ if (this.user) {
+ try {
+ this.cb.call(this.vm, value, oldValue);
+ } catch (e) {
+ /* istanbul ignore else */
+ if (config.errorHandler) {
+ config.errorHandler.call(null, e, this.vm);
+ } else {
+ "development" !== 'production' && warn(
+ ("Error in watcher \"" + (this.expression) + "\""),
+ this.vm
+ );
+ throw e
+ }
+ }
+ } else {
+ this.cb.call(this.vm, value, oldValue);
+ }
+ }
}
-}
+};
-/* */
+/**
+ * Evaluate the value of the watcher.
+ * This only gets called for lazy watchers.
+ */
+Watcher.prototype.evaluate = function evaluate () {
+ this.value = this.get();
+ this.dirty = false;
+};
-var SIMPLE_NORMALIZE = 1;
-var ALWAYS_NORMALIZE = 2;
+/**
+ * Depend on all deps collected by this watcher.
+ */
+Watcher.prototype.depend = function depend () {
+ var this$1 = this;
-// wrapper function for providing a more flexible interface
-// without getting yelled at by flow
-function createElement (
- context,
- tag,
- data,
- children,
- normalizationType,
- alwaysNormalize
-) {
- if (Array.isArray(data) || isPrimitive(data)) {
- normalizationType = children;
- children = data;
- data = undefined;
+ var i = this.deps.length;
+ while (i--) {
+ this$1.deps[i].depend();
}
- if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
- return _createElement(context, tag, data, children, normalizationType)
-}
+};
-function _createElement (
- context,
- tag,
- data,
- children,
- normalizationType
-) {
- if (data && data.__ob__) {
- "development" !== 'production' && warn(
- "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
- 'Always create fresh vnode data objects in each render!',
- context
- );
- return createEmptyVNode()
- }
- if (!tag) {
- // in case of component :is set to falsy value
- return createEmptyVNode()
- }
- // support single function children as default scoped slot
- if (Array.isArray(children) &&
- typeof children[0] === 'function') {
- data = data || {};
- data.scopedSlots = { default: children[0] };
- children.length = 0;
- }
- if (normalizationType === ALWAYS_NORMALIZE) {
- children = normalizeChildren(children);
- } else if (normalizationType === SIMPLE_NORMALIZE) {
- children = simpleNormalizeChildren(children);
- }
- var vnode, ns;
- if (typeof tag === 'string') {
- var Ctor;
- ns = config.getTagNamespace(tag);
- if (config.isReservedTag(tag)) {
- // platform built-in elements
- vnode = new VNode(
- config.parsePlatformTagName(tag), data, children,
- undefined, undefined, context
- );
- } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
- // component
- vnode = createComponent(Ctor, data, context, children, tag);
- } else {
- // unknown or unlisted namespaced elements
- // check at runtime because it may get assigned a namespace when its
- // parent normalizes children
- vnode = new VNode(
- tag, data, children,
- undefined, undefined, context
- );
+/**
+ * Remove self from all dependencies' subscriber list.
+ */
+Watcher.prototype.teardown = function teardown () {
+ var this$1 = this;
+
+ if (this.active) {
+ // remove self from vm's watcher list
+ // this is a somewhat expensive operation so we skip it
+ // if the vm is being destroyed.
+ if (!this.vm._isBeingDestroyed) {
+ remove(this.vm._watchers, this);
}
- } else {
- // direct component options / constructor
- vnode = createComponent(tag, data, context, children);
- }
- if (vnode) {
- if (ns) { applyNS(vnode, ns); }
- return vnode
- } else {
- return createEmptyVNode()
+ var i = this.deps.length;
+ while (i--) {
+ this$1.deps[i].removeSub(this$1);
+ }
+ this.active = false;
}
+};
+
+/**
+ * Recursively traverse an object to evoke all converted
+ * getters, so that every nested property inside the object
+ * is collected as a "deep" dependency.
+ */
+var seenObjects = new _Set();
+function traverse (val) {
+ seenObjects.clear();
+ _traverse(val, seenObjects);
}
-function applyNS (vnode, ns) {
- vnode.ns = ns;
- if (vnode.tag === 'foreignObject') {
- // use default namespace inside foreignObject
+function _traverse (val, seen) {
+ var i, keys;
+ var isA = Array.isArray(val);
+ if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
return
}
- if (vnode.children) {
- for (var i = 0, l = vnode.children.length; i < l; i++) {
- var child = vnode.children[i];
- if (child.tag && !child.ns) {
- applyNS(child, ns);
- }
+ if (val.__ob__) {
+ var depId = val.__ob__.dep.id;
+ if (seen.has(depId)) {
+ return
}
+ seen.add(depId);
+ }
+ if (isA) {
+ i = val.length;
+ while (i--) { _traverse(val[i], seen); }
+ } else {
+ keys = Object.keys(val);
+ i = keys.length;
+ while (i--) { _traverse(val[keys[i]], seen); }
}
}
/* */
-function initRender (vm) {
- vm.$vnode = null; // the placeholder node in parent tree
- vm._vnode = null; // the root of the child tree
- vm._staticTrees = null;
- var parentVnode = vm.$options._parentVnode;
- var renderContext = parentVnode && parentVnode.context;
- vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
- vm.$scopedSlots = {};
- // bind the createElement fn to this instance
- // so that we get proper render context inside it.
- // args order: tag, data, children, normalizationType, alwaysNormalize
- // internal version is used by render functions compiled from templates
- vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
- // normalization is always applied for the public version, used in
- // user-written render functions.
- vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
- if (vm.$options.el) {
- vm.$mount(vm.$options.el);
+function initState (vm) {
+ vm._watchers = [];
+ var opts = vm.$options;
+ if (opts.props) { initProps(vm, opts.props); }
+ if (opts.methods) { initMethods(vm, opts.methods); }
+ if (opts.data) {
+ initData(vm);
+ } else {
+ observe(vm._data = {}, true /* asRootData */);
}
+ if (opts.computed) { initComputed(vm, opts.computed); }
+ if (opts.watch) { initWatch(vm, opts.watch); }
}
-function renderMixin (Vue) {
- Vue.prototype.$nextTick = function (fn) {
- return nextTick(fn, this)
- };
-
- Vue.prototype._render = function () {
- var vm = this;
- var ref = vm.$options;
- var render = ref.render;
- var staticRenderFns = ref.staticRenderFns;
- var _parentVnode = ref._parentVnode;
-
- if (vm._isMounted) {
- // clone slot nodes on re-renders
- for (var key in vm.$slots) {
- vm.$slots[key] = cloneVNodes(vm.$slots[key]);
- }
- }
-
- if (_parentVnode && _parentVnode.data.scopedSlots) {
- vm.$scopedSlots = _parentVnode.data.scopedSlots;
- }
+var isReservedProp = { key: 1, ref: 1, slot: 1 };
- if (staticRenderFns && !vm._staticTrees) {
- vm._staticTrees = [];
- }
- // set parent vnode. this allows render functions to have access
- // to the data on the placeholder node.
- vm.$vnode = _parentVnode;
- // render self
- var vnode;
- try {
- vnode = render.call(vm._renderProxy, vm.$createElement);
- } catch (e) {
- /* istanbul ignore else */
- if (config.errorHandler) {
- config.errorHandler.call(null, e, vm);
- } else {
- {
- warn(("Error when rendering " + (formatComponentName(vm)) + ":"));
- }
- throw e
- }
- // return previous vnode to prevent render error causing blank component
- vnode = vm._vnode;
- }
- // return empty vnode in case the render function errored out
- if (!(vnode instanceof VNode)) {
- if ("development" !== 'production' && Array.isArray(vnode)) {
+function initProps (vm, props) {
+ var propsData = vm.$options.propsData || {};
+ var keys = vm.$options._propKeys = Object.keys(props);
+ var isRoot = !vm.$parent;
+ // root instance props should be converted
+ observerState.shouldConvert = isRoot;
+ var loop = function ( i ) {
+ var key = keys[i];
+ /* istanbul ignore else */
+ {
+ if (isReservedProp[key]) {
warn(
- 'Multiple root nodes returned from render function. Render function ' +
- 'should return a single root node.',
+ ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
vm
);
}
- vnode = createEmptyVNode();
+ defineReactive$$1(vm, key, validateProp(key, props, propsData, vm), function () {
+ if (vm.$parent && !observerState.isSettingProps) {
+ warn(
+ "Avoid mutating a prop directly since the value will be " +
+ "overwritten whenever the parent component re-renders. " +
+ "Instead, use a data or computed property based on the prop's " +
+ "value. Prop being mutated: \"" + key + "\"",
+ vm
+ );
+ }
+ });
}
- // set parent
- vnode.parent = _parentVnode;
- return vnode
};
- // toString for mustaches
- Vue.prototype._s = _toString;
- // convert text to vnode
- Vue.prototype._v = createTextVNode;
- // number conversion
- Vue.prototype._n = toNumber;
- // empty vnode
- Vue.prototype._e = createEmptyVNode;
- // loose equal
- Vue.prototype._q = looseEqual;
- // loose indexOf
- Vue.prototype._i = looseIndexOf;
+ for (var i = 0; i < keys.length; i++) { loop( i ); }
+ observerState.shouldConvert = true;
+}
- // render static tree by index
- Vue.prototype._m = function renderStatic (
- index,
- isInFor
- ) {
- var tree = this._staticTrees[index];
- // if has already-rendered static tree and not inside v-for,
- // we can reuse the same tree by doing a shallow clone.
- if (tree && !isInFor) {
- return Array.isArray(tree)
- ? cloneVNodes(tree)
- : cloneVNode(tree)
+function initData (vm) {
+ var data = vm.$options.data;
+ data = vm._data = typeof data === 'function'
+ ? data.call(vm)
+ : data || {};
+ if (!isPlainObject(data)) {
+ data = {};
+ "development" !== 'production' && warn(
+ 'data functions should return an object:\n' +
+ 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
+ vm
+ );
+ }
+ // proxy data on instance
+ var keys = Object.keys(data);
+ var props = vm.$options.props;
+ var i = keys.length;
+ while (i--) {
+ if (props && hasOwn(props, keys[i])) {
+ "development" !== 'production' && warn(
+ "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
+ "Use prop default value instead.",
+ vm
+ );
+ } else {
+ proxy(vm, keys[i]);
}
- // otherwise, render a fresh tree.
- tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
- markStatic(tree, ("__static__" + index), false);
- return tree
- };
+ }
+ // observe data
+ observe(data, true /* asRootData */);
+}
- // mark node as static (v-once)
- Vue.prototype._o = function markOnce (
- tree,
- index,
- key
- ) {
- markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
- return tree
- };
+var computedSharedDefinition = {
+ enumerable: true,
+ configurable: true,
+ get: noop,
+ set: noop
+};
- function markStatic (tree, key, isOnce) {
- if (Array.isArray(tree)) {
- for (var i = 0; i < tree.length; i++) {
- if (tree[i] && typeof tree[i] !== 'string') {
- markStaticNode(tree[i], (key + "_" + i), isOnce);
- }
- }
+function initComputed (vm, computed) {
+ for (var key in computed) {
+ /* istanbul ignore if */
+ if ("development" !== 'production' && key in vm) {
+ warn(
+ "existing instance property \"" + key + "\" will be " +
+ "overwritten by a computed property with the same name.",
+ vm
+ );
+ }
+ var userDef = computed[key];
+ if (typeof userDef === 'function') {
+ computedSharedDefinition.get = makeComputedGetter(userDef, vm);
+ computedSharedDefinition.set = noop;
} else {
- markStaticNode(tree, key, isOnce);
+ computedSharedDefinition.get = userDef.get
+ ? userDef.cache !== false
+ ? makeComputedGetter(userDef.get, vm)
+ : bind(userDef.get, vm)
+ : noop;
+ computedSharedDefinition.set = userDef.set
+ ? bind(userDef.set, vm)
+ : noop;
}
+ Object.defineProperty(vm, key, computedSharedDefinition);
}
+}
- function markStaticNode (node, key, isOnce) {
- node.isStatic = true;
- node.key = key;
- node.isOnce = isOnce;
+function makeComputedGetter (getter, owner) {
+ var watcher = new Watcher(owner, getter, noop, {
+ lazy: true
+ });
+ return function computedGetter () {
+ if (watcher.dirty) {
+ watcher.evaluate();
+ }
+ if (Dep.target) {
+ watcher.depend();
+ }
+ return watcher.value
}
+}
- // filter resolution helper
- Vue.prototype._f = function resolveFilter (id) {
- return resolveAsset(this.$options, 'filters', id, true) || identity
- };
-
- // render v-for
- Vue.prototype._l = function renderList (
- val,
- render
- ) {
- var ret, i, l, keys, key;
- if (Array.isArray(val) || typeof val === 'string') {
- ret = new Array(val.length);
- for (i = 0, l = val.length; i < l; i++) {
- ret[i] = render(val[i], i);
- }
- } else if (typeof val === 'number') {
- ret = new Array(val);
- for (i = 0; i < val; i++) {
- ret[i] = render(i + 1, i);
- }
- } else if (isObject(val)) {
- keys = Object.keys(val);
- ret = new Array(keys.length);
- for (i = 0, l = keys.length; i < l; i++) {
- key = keys[i];
- ret[i] = render(val[key], key, i);
- }
+function initMethods (vm, methods) {
+ for (var key in methods) {
+ vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
+ if ("development" !== 'production' && methods[key] == null) {
+ warn(
+ "method \"" + key + "\" has an undefined value in the component definition. " +
+ "Did you reference the function correctly?",
+ vm
+ );
}
- return ret
- };
+ }
+}
- // renderSlot
- Vue.prototype._t = function (
- name,
- fallback,
- props,
- bindObject
- ) {
- var scopedSlotFn = this.$scopedSlots[name];
- if (scopedSlotFn) { // scoped slot
- props = props || {};
- if (bindObject) {
- extend(props, bindObject);
+function initWatch (vm, watch) {
+ for (var key in watch) {
+ var handler = watch[key];
+ if (Array.isArray(handler)) {
+ for (var i = 0; i < handler.length; i++) {
+ createWatcher(vm, key, handler[i]);
}
- return scopedSlotFn(props) || fallback
} else {
- var slotNodes = this.$slots[name];
- // warn duplicate slot usage
- if (slotNodes && "development" !== 'production') {
- slotNodes._rendered && warn(
- "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
- "- this will likely cause render errors.",
- this
- );
- slotNodes._rendered = true;
- }
- return slotNodes || fallback
+ createWatcher(vm, key, handler);
}
- };
+ }
+}
- // apply v-bind object
- Vue.prototype._b = function bindProps (
- data,
- tag,
- value,
- asProp
- ) {
- if (value) {
- if (!isObject(value)) {
- "development" !== 'production' && warn(
- 'v-bind without argument expects an Object or Array value',
- this
- );
- } else {
- if (Array.isArray(value)) {
- value = toObject(value);
- }
- for (var key in value) {
- if (key === 'class' || key === 'style') {
- data[key] = value[key];
- } else {
- var hash = asProp || config.mustUseProp(tag, key)
- ? data.domProps || (data.domProps = {})
- : data.attrs || (data.attrs = {});
- hash[key] = value[key];
- }
- }
- }
- }
- return data
+function createWatcher (vm, key, handler) {
+ var options;
+ if (isPlainObject(handler)) {
+ options = handler;
+ handler = handler.handler;
+ }
+ if (typeof handler === 'string') {
+ handler = vm[handler];
+ }
+ vm.$watch(key, handler, options);
+}
+
+function stateMixin (Vue) {
+ // flow somehow has problems with directly declared definition object
+ // when using Object.defineProperty, so we have to procedurally build up
+ // the object here.
+ var dataDef = {};
+ dataDef.get = function () {
+ return this._data
};
+ {
+ dataDef.set = function (newData) {
+ warn(
+ 'Avoid replacing instance root $data. ' +
+ 'Use nested data properties instead.',
+ this
+ );
+ };
+ }
+ Object.defineProperty(Vue.prototype, '$data', dataDef);
- // check v-on keyCodes
- Vue.prototype._k = function checkKeyCodes (
- eventKeyCode,
- key,
- builtInAlias
+ Vue.prototype.$set = set$1;
+ Vue.prototype.$delete = del;
+
+ Vue.prototype.$watch = function (
+ expOrFn,
+ cb,
+ options
) {
- var keyCodes = config.keyCodes[key] || builtInAlias;
- if (Array.isArray(keyCodes)) {
- return keyCodes.indexOf(eventKeyCode) === -1
- } else {
- return keyCodes !== eventKeyCode
+ var vm = this;
+ options = options || {};
+ options.user = true;
+ var watcher = new Watcher(vm, expOrFn, cb, options);
+ if (options.immediate) {
+ cb.call(vm, watcher.value);
+ }
+ return function unwatchFn () {
+ watcher.teardown();
}
};
}
-function resolveSlots (
- children,
- context
-) {
- var slots = {};
- if (!children) {
- return slots
- }
- var defaultSlot = [];
- var name, child;
- for (var i = 0, l = children.length; i < l; i++) {
- child = children[i];
- // named slots should only be respected if the vnode was rendered in the
- // same context.
- if ((child.context === context || child.functionalContext === context) &&
- child.data && (name = child.data.slot)) {
- var slot = (slots[name] || (slots[name] = []));
- if (child.tag === 'template') {
- slot.push.apply(slot, child.children);
- } else {
- slot.push(child);
+function proxy (vm, key) {
+ if (!isReserved(key)) {
+ Object.defineProperty(vm, key, {
+ configurable: true,
+ enumerable: true,
+ get: function proxyGetter () {
+ return vm._data[key]
+ },
+ set: function proxySetter (val) {
+ vm._data[key] = val;
}
- } else {
- defaultSlot.push(child);
- }
- }
- // ignore single whitespace
- if (defaultSlot.length && !(
- defaultSlot.length === 1 &&
- (defaultSlot[0].text === ' ' || defaultSlot[0].isComment)
- )) {
- slots.default = defaultSlot;
+ });
}
- return slots
}
/* */
@@ -7191,6 +7201,10 @@ function insertBefore (node, target, before) {
}
function removeChild (node, child) {
+ if (child.nodeType === 3) {
+ node.setAttr('value', '');
+ return
+ }
node.removeChild(child);
}
@@ -8355,7 +8369,7 @@ function createInstance (
var weexInstanceVar = {
config: config,
document: document,
- require: moduleGetter
+ requireModule: moduleGetter
};
Object.freeze(weexInstanceVar);
@@ -13423,8 +13437,8 @@ function init$5 (app, code, data, services) {
config: app.options,
define: bundleDefine,
bootstrap: bundleBootstrap,
- require: bundleDocument,
- document: bundleRequireModule,
+ requireModule: bundleRequireModule,
+ document: bundleDocument,
Vm: bundleVm
};
@@ -13443,7 +13457,7 @@ function init$5 (app, code, data, services) {
functionBody = code.toString();
}
// wrap IFFE and use strict mode
- functionBody = "(function(global){\n\n\"use strict\";\n\n " + functionBody + " \n\n})(Object.create(this))";
+ functionBody = "(function(global){\n\n " + functionBody + " \n\n})(Object.create(this))";
// run code and get result
var WXEnvironment = global.WXEnvironment;
@@ -13485,6 +13499,7 @@ function init$5 (app, code, data, services) {
var globalObjects = Object.assign({
define: bundleDefine,
require: bundleRequire,
+ document: bundleDocument,
bootstrap: bundleBootstrap,
register: bundleRegister,
render: bundleRender,
@@ -13939,16 +13954,20 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
\**************************************************/
/***/ function(module, exports, __webpack_require__) {
- 'use strict';
-
+ "use strict";
+
Object.defineProperty(exports, "__esModule", {
value: true
});
-
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) { break; } } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) { _i["return"](); } } finally { if (_d) { throw _e; } } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
-
+
+ var _extends = Object.assign || function (target) {
+ var arguments$1 = arguments;
+ for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
+
exports.getInstance = getInstance;
exports.init = init;
exports.registerComponents = registerComponents;
@@ -13959,28 +13978,33 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
exports.destroyInstance = destroyInstance;
exports.getRoot = getRoot;
exports.receiveTasks = receiveTasks;
-
+
var _builtin = __webpack_require__(/*! ./builtin */ 1);
-
+
var _emitter = __webpack_require__(/*! ./emitter */ 3);
-
+
var _emitter2 = _interopRequireDefault(_emitter);
-
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
-
+
var NativeComponents = {};
var NativeModules = {};
-
+
var Document = void 0;
var Element = void 0;
var Comment = void 0;
var Listener = void 0;
+ var TaskCenter = void 0;
+ var CallbackManager = void 0;
var sendTasks = void 0;
-
+
+ var MODULE_NAME_PREFIX = '@weex-module/';
+ var MODAL_MODULE = MODULE_NAME_PREFIX + 'modal';
+ var DOM_MODULE = MODULE_NAME_PREFIX + 'dom';
+ var NAVIGATOR_MODULE = MODULE_NAME_PREFIX + 'navigator';
+ // Instance hub
var instances = {};
-
+
function dispatchEventToInstance(event, targetOrigin) {
var instance;
for (var i in instances) {
@@ -13994,7 +14018,7 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
}
}
}
-
+
function getInstance(instanceId) {
var instance = instances[instanceId];
if (!instance) {
@@ -14002,15 +14026,17 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
}
return instance;
}
-
- function init(cfg) {
- Document = cfg.Document;
- Element = cfg.Element;
- Comment = cfg.Comment;
- Listener = cfg.Listener;
- sendTasks = cfg.sendTasks;
+
+ function init(config) {
+ Document = config.Document;
+ Element = config.Element;
+ Comment = config.Comment;
+ Listener = config.Listener;
+ TaskCenter = config.TaskCenter;
+ CallbackManager = config.CallbackManager;
+ sendTasks = config.sendTasks;
}
-
+
/**
* register the name of each native component
* @param {array} components array of name
@@ -14030,17 +14056,15 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
});
}
}
-
+
/**
* register the name and methods of each api
* @param {object} apis a object of apis
*/
- function registerMethods(apis) {
- if ((typeof apis === 'undefined' ? 'undefined' : _typeof(apis)) === 'object') {
- // Noop
- }
- }
-
+ function registerMethods(apis) {}
+ // Noop
+
+
/**
* register the name and methods of each module
* @param {object} modules a object of modules
@@ -14054,63 +14078,49 @@ module.exports = /******/ (function(modules) { // webpackBootstrap
}
}
}
-
- function genBuiltinModules(modules,
- // ES
- Promise,
- // W3C
- window, screen, document, navigator, location, fetch, Headers, Response, Request, URL, URLSearchParams, setTimeout, clearTimeout, setInterval, clearInterval, requestAnimationFrame, cancelAnimationFrame, alert,
- // Weex
- __weex_define__, __weex_require__, __weex_options__, __weex_data__, __weex_downgrade__, __weex_document__) {
- for (var moduleName in _builtin.BuiltinModulesFactory) {
+
+ function genBuiltinModules(modules, moduleFactories,
<TRUNCATED>