From 37e4b67ab9c15769ec56c4baefb1fc3c1d446199 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 22 Jan 2019 20:47:26 +1100 Subject: [PATCH] V5.0 (#2617) * Add URL link directly to client view in list view * Implement Form requests for all client routes * Refactor how permissions are implemented on Datatable row action menus * fixes for tests * bug fix * Add ctrans global function for custom translations. Reduced DB queries for Client List. Added Debugbar for dev environments * ctrans --- app/Datatables/MakesActionMenu.php | 4 +- app/Helpers/TranslationHelper.php | 20 + app/Http/Controllers/ClientController.php | 4 +- app/Models/Client.php | 2 + app/Models/User.php | 38 +- app/Policies/EntityPolicy.php | 11 +- app/Providers/AppServiceProvider.php | 9 +- app/Providers/RouteServiceProvider.php | 2 +- composer.json | 1 + composer.lock | 131 ++- public/js/client_list.js | 915 ++++++++++-------- public/js/client_list.min.js | 915 ++++++++++-------- .../js/src/components/util/VueListActions.vue | 2 +- 13 files changed, 1252 insertions(+), 802 deletions(-) create mode 100644 app/Helpers/TranslationHelper.php diff --git a/app/Datatables/MakesActionMenu.php b/app/Datatables/MakesActionMenu.php index a2e64c6999f5..a4c0e5f6c5b9 100644 --- a/app/Datatables/MakesActionMenu.php +++ b/app/Datatables/MakesActionMenu.php @@ -95,10 +95,10 @@ trait MakesActionMenu * @param bool $isAdmin Boolean isAdmin * @return Collection collection of filtered actions available to the user */ - public function filterActions(array $actions, array $permissions, bool $isAdmin) :Collection + public function filterActions(array $actions, array $permissions, bool $is_admin) :Collection { - return $this->checkPermissions($this->actions()->whereIn('action', $actions), $permissions, $isAdmin); + return $this->checkPermissions($this->actions()->whereIn('action', $actions), $permissions, $is_admin); } diff --git a/app/Helpers/TranslationHelper.php b/app/Helpers/TranslationHelper.php new file mode 100644 index 000000000000..b5d9dab399c1 --- /dev/null +++ b/app/Helpers/TranslationHelper.php @@ -0,0 +1,20 @@ +user()); if(request('page')) return $this->clientDatatable->query(request(), $this->getCurrentCompanyId()); @@ -124,7 +125,6 @@ class ClientController extends Controller */ public function edit(EditClientRequest $request, Client $client) { - $data = [ 'client' => $client, 'settings' => [], diff --git a/app/Models/Client.php b/app/Models/Client.php index aed96e5af895..2cdf73b9e390 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -27,6 +27,8 @@ class Client extends BaseModel 'q' ]; + protected $with = ['contacts', 'primary_contact']; + //protected $dates = ['deleted_at']; public function getHashedIdAttribute() diff --git a/app/Models/User.php b/app/Models/User.php index acdc8fa0bd1d..778e4ee70988 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Models\CompanyUser; use App\Models\Traits\UserTrait; use App\Utils\Traits\MakesHash; use App\Utils\Traits\UserSessionAttributes; @@ -28,6 +29,7 @@ class User extends Authenticatable implements MustVerifyEmail protected $presenter = 'App\Models\Presenters\UserPresenter'; + protected $with = ['companies', 'user_companies']; /** * The attributes that are mass assignable. * @@ -69,13 +71,24 @@ class User extends Authenticatable implements MustVerifyEmail } /** - * Returns the current company + * Returns the pivot tables for Company / User + * + * @return Collection + */ + public function user_companies() + { + return $this->hasMany(CompanyUser::class); + } + + /** + * Returns the current company by + * querying directly on the pivot table relationship * * @return Collection */ public function company() { - return $this->companies()->where('company_id', $this->getCurrentCompanyId())->first(); + return $this->user_companies->where('company_id', $this->getCurrentCompanyId())->first(); } /** @@ -86,7 +99,7 @@ class User extends Authenticatable implements MustVerifyEmail public function permissions() { - $permissions = json_decode($this->company()->pivot->permissions); + $permissions = json_decode($this->company()->permissions); if (! $permissions) return []; @@ -101,7 +114,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function settings() { - return json_decode($this->company()->pivot->settings); + + return json_decode($this->company()->settings); + } /** @@ -111,7 +126,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function isAdmin() : bool { - return (bool) $this->company()->pivot->is_admin; + + return (bool) $this->company()->is_admin; + } /** @@ -121,7 +138,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function contacts() { + return $this->hasMany(Contact::class); + } /** @@ -132,7 +151,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function owns($entity) : bool { + return ! empty($entity->user_id) && $entity->user_id == $this->id; + } /** @@ -143,7 +164,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function permissionsFlat() :Collection { + return collect($this->permissions())->flatten(); + } /** @@ -154,7 +177,9 @@ class User extends Authenticatable implements MustVerifyEmail */ public function hasPermission($permission) : bool { + return $this->permissionsFlat()->contains($permission); + } /** @@ -162,13 +187,14 @@ class User extends Authenticatable implements MustVerifyEmail * * @return array */ - public function permissionsMap() + public function permissionsMap() : array { $keys = array_values((array) $this->permissions()); $values = array_fill(0, count($keys), true); return array_combine($keys, $values); + } } diff --git a/app/Policies/EntityPolicy.php b/app/Policies/EntityPolicy.php index 3af22130f991..eab9a1343d0f 100644 --- a/app/Policies/EntityPolicy.php +++ b/app/Policies/EntityPolicy.php @@ -38,9 +38,11 @@ class EntityPolicy */ public function edit(User $user, $entity) : bool { - return ($user->isAdmin() && $entity->company_id == $user->company()->pivot->company_id) - || ($user->hasPermission('edit_' . strtolower(class_basename($entity))) && $entity->company_id == $user->company()->pivot->company_id) + + return ($user->isAdmin() && $entity->company_id == $user->company()->company_id) + || ($user->hasPermission('edit_' . strtolower(class_basename($entity))) && $entity->company_id == $user->company()->company_id) || $user->owns($entity); + } @@ -54,8 +56,9 @@ class EntityPolicy */ public function view(User $user, $entity) : bool { - return ($user->isAdmin() && $entity->company_id == $user->company()->pivot->company_id) - || ($user->hasPermission('view_' . strtolower(class_basename($entity))) && $entity->company_id == $user->company()->pivot->company_id) + + return ($user->isAdmin() && $entity->company_id == $user->company()->company_id) + || ($user->hasPermission('view_' . strtolower(class_basename($entity))) && $entity->company_id == $user->company()->company_id) || $user->owns($entity); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 380458a57e22..eccc1d535b79 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -32,6 +32,13 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - // + $this->loadHelpers(); + } + + protected function loadHelpers() + { + foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) { + require_once $filename; + } } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 8b720431f4ea..9a85e837e50e 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider Route::bind('client', function ($value) { $client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404); - $client->load('contacts', 'primary_contact'); + //$client->load('contacts', 'primary_contact'); return $client; }); diff --git a/composer.json b/composer.json index d9d49662bd91..2f67149e438c 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "wildbit/postmark-php": "^2.6" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.2", "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", diff --git a/composer.lock b/composer.lock index 0a1ce42f8c0c..fb3d76cf1055 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f070f7f4ccfe346840e4dfd0e39650a5", + "content-hash": "b41a1819d57b9ee31cec2012cc37704f", "packages": [ { "name": "asgrim/ofxparser", @@ -3796,6 +3796,74 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "9d5caf43c5f3a3aea2178942f281054805872e7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/9d5caf43c5f3a3aea2178942f281054805872e7c", + "reference": "9d5caf43c5f3a3aea2178942f281054805872e7c", + "shasum": "" + }, + "require": { + "illuminate/routing": "5.5.x|5.6.x|5.7.x", + "illuminate/session": "5.5.x|5.6.x|5.7.x", + "illuminate/support": "5.5.x|5.6.x|5.7.x", + "maximebf/debugbar": "~1.15.0", + "php": ">=7.0", + "symfony/debug": "^3|^4", + "symfony/finder": "^3|^4" + }, + "require-dev": { + "laravel/framework": "5.5.x" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2018-11-09T08:37:55+00:00" + }, { "name": "beyondcode/laravel-dump-server", "version": "1.2.2", @@ -4191,6 +4259,67 @@ ], "time": "2019-01-10T14:22:35+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/30e7d60937ee5f1320975ca9bc7bcdd44d500f07", + "reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3.0|^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.14-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2017-12-15T11:13:46+00:00" + }, { "name": "mockery/mockery", "version": "1.2.0", diff --git a/public/js/client_list.js b/public/js/client_list.js index 7cc9af0e1d11..5973b78c595e 100644 --- a/public/js/client_list.js +++ b/public/js/client_list.js @@ -2986,7 +2986,7 @@ module.exports = function (it) { /***/ "./node_modules/core-js/library/modules/_core.js": /***/ (function(module, exports) { -var core = module.exports = { version: '2.5.7' }; +var core = module.exports = { version: '2.6.1' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef @@ -10385,7 +10385,7 @@ if(false) { "use strict"; /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! - * Vue.js v2.5.17 + * Vue.js v2.5.21 * (c) 2014-2018 Evan You * Released under the MIT License. */ @@ -10395,8 +10395,8 @@ if(false) { var emptyObject = Object.freeze({}); -// these helpers produces better vm code in JS engines due to their -// explicitness and function inlining +// These helpers produce better VM code in JS engines due to their +// explicitness and function inlining. function isUndef (v) { return v === undefined || v === null } @@ -10414,7 +10414,7 @@ function isFalse (v) { } /** - * Check if value is primitive + * Check if value is primitive. */ function isPrimitive (value) { return ( @@ -10436,7 +10436,7 @@ function isObject (obj) { } /** - * Get the raw type string of a value e.g. [object Object] + * Get the raw type string of a value, e.g., [object Object]. */ var _toString = Object.prototype.toString; @@ -10476,7 +10476,7 @@ function toString (val) { } /** - * Convert a input value to a number for persistence. + * Convert an input value to a number for persistence. * If the conversion fails, return original string. */ function toNumber (val) { @@ -10508,12 +10508,12 @@ function makeMap ( var isBuiltInTag = makeMap('slot,component', true); /** - * Check if a attribute is a reserved attribute. + * Check if an attribute is a reserved attribute. */ var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); /** - * Remove an item from an array + * Remove an item from an array. */ function remove (arr, item) { if (arr.length) { @@ -10525,7 +10525,7 @@ function remove (arr, item) { } /** - * Check whether the object has the property. + * Check whether an object has the property. */ var hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwn (obj, key) { @@ -10567,11 +10567,11 @@ var hyphenate = cached(function (str) { }); /** - * Simple bind polyfill for environments that do not support it... e.g. - * PhantomJS 1.x. Technically we don't need this anymore since native bind is - * now more performant in most browsers, but removing it would be breaking for - * code that was able to run in PhantomJS 1.x, so this must be kept for - * backwards compatibility. + * Simple bind polyfill for environments that do not support it, + * e.g., PhantomJS 1.x. Technically, we don't need this anymore + * since native bind is now performant enough in most browsers. + * But removing it would mean breaking code that was able to run in + * PhantomJS 1.x, so this must be kept for backward compatibility. */ /* istanbul ignore next */ @@ -10633,10 +10633,12 @@ function toObject (arr) { return res } +/* eslint-disable no-unused-vars */ + /** * Perform no operation. * Stubbing args to make Flow happy without leaving useless transpiled code - * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). */ function noop (a, b, c) {} @@ -10645,13 +10647,15 @@ function noop (a, b, c) {} */ var no = function (a, b, c) { return false; }; +/* eslint-enable no-unused-vars */ + /** - * Return same value + * Return the same value. */ var identity = function (_) { return _; }; /** - * Generate a static keys string from compiler modules. + * Generate a string containing static keys from compiler modules. */ function genStaticKeys (modules) { return modules.reduce(function (keys, m) { @@ -10675,6 +10679,8 @@ function looseEqual (a, b) { return a.length === b.length && a.every(function (e, i) { return looseEqual(e, b[i]) }) + } else if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime() } else if (!isArrayA && !isArrayB) { var keysA = Object.keys(a); var keysB = Object.keys(b); @@ -10696,6 +10702,11 @@ function looseEqual (a, b) { } } +/** + * Return the first index at which a loosely equal value can be + * found in the array (if value is a plain object, the array must + * contain an object of the same shape), or -1 if it is not present. + */ function looseIndexOf (arr, val) { for (var i = 0; i < arr.length; i++) { if (looseEqual(arr[i], val)) { return i } @@ -10740,6 +10751,8 @@ var LIFECYCLE_HOOKS = [ /* */ + + var config = ({ /** * Option merge strategies (used in core/util/options) @@ -10822,11 +10835,17 @@ var config = ({ */ mustUseProp: no, + /** + * Perform updates asynchronously. Intended to be used by Vue Test Utils + * This will significantly reduce performance if set to false. + */ + async: true, + /** * Exposed for legacy reasons */ _lifecycleHooks: LIFECYCLE_HOOKS -}) +}); /* */ @@ -10911,7 +10930,7 @@ var isServerRendering = function () { if (!inBrowser && !inWeex && typeof global !== 'undefined') { // detect presence of vue-server-renderer and avoid // Webpack shimming the process - _isServer = global['process'].env.VUE_ENV === 'server'; + _isServer = global['process'] && global['process'].env.VUE_ENV === 'server'; } else { _isServer = false; } @@ -10938,7 +10957,7 @@ if (typeof Set !== 'undefined' && isNative(Set)) { _Set = Set; } else { // a non-standard Set polyfill that only works with primitive keys. - _Set = (function () { + _Set = /*@__PURE__*/(function () { function Set () { this.set = Object.create(null); } @@ -11052,7 +11071,6 @@ if (true) { /* */ - var uid = 0; /** @@ -11081,6 +11099,12 @@ Dep.prototype.depend = function depend () { Dep.prototype.notify = function notify () { // stabilize the subscriber list first var subs = this.subs.slice(); + if ("development" !== 'production' && !config.async) { + // subs aren't sorted in scheduler if not running async + // we need to sort them now to make sure they fire in correct + // order + subs.sort(function (a, b) { return a.id - b.id; }); + } for (var i = 0, l = subs.length; i < l; i++) { subs[i].update(); } @@ -11092,13 +11116,14 @@ Dep.prototype.notify = function notify () { Dep.target = null; var targetStack = []; -function pushTarget (_target) { - if (Dep.target) { targetStack.push(Dep.target); } - Dep.target = _target; +function pushTarget (target) { + targetStack.push(target); + Dep.target = target; } function popTarget () { - Dep.target = targetStack.pop(); + targetStack.pop(); + Dep.target = targetStack[targetStack.length - 1]; } /* */ @@ -11169,7 +11194,10 @@ function cloneVNode (vnode) { var cloned = new VNode( vnode.tag, vnode.data, - vnode.children, + // #7975 + // clone children array to avoid mutating original in case of cloning + // a child. + vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, @@ -11183,6 +11211,7 @@ function cloneVNode (vnode) { cloned.fnContext = vnode.fnContext; cloned.fnOptions = vnode.fnOptions; cloned.fnScopeId = vnode.fnScopeId; + cloned.asyncMeta = vnode.asyncMeta; cloned.isCloned = true; return cloned } @@ -11260,10 +11289,11 @@ var Observer = function Observer (value) { this.vmCount = 0; def(value, '__ob__', this); if (Array.isArray(value)) { - var augment = hasProto - ? protoAugment - : copyAugment; - augment(value, arrayMethods, arrayKeys); + if (hasProto) { + protoAugment(value, arrayMethods); + } else { + copyAugment(value, arrayMethods, arrayKeys); + } this.observeArray(value); } else { this.walk(value); @@ -11271,14 +11301,14 @@ var Observer = function Observer (value) { }; /** - * Walk through each property and convert them into + * Walk through all properties and convert them into * getter/setters. This method should only be called when * value type is Object. */ Observer.prototype.walk = function walk (obj) { var keys = Object.keys(obj); for (var i = 0; i < keys.length; i++) { - defineReactive(obj, keys[i]); + defineReactive$$1(obj, keys[i]); } }; @@ -11294,17 +11324,17 @@ Observer.prototype.observeArray = function observeArray (items) { // helpers /** - * Augment an target Object or Array by intercepting + * Augment a target Object or Array by intercepting * the prototype chain using __proto__ */ -function protoAugment (target, src, keys) { +function protoAugment (target, src) { /* eslint-disable no-proto */ target.__proto__ = src; /* eslint-enable no-proto */ } /** - * Augment an target Object or Array by defining + * Augment a target Object or Array by defining * hidden properties. */ /* istanbul ignore next */ @@ -11345,7 +11375,7 @@ function observe (value, asRootData) { /** * Define a reactive property on an Object. */ -function defineReactive ( +function defineReactive$$1 ( obj, key, val, @@ -11361,10 +11391,10 @@ function defineReactive ( // cater for pre-defined getter/setters var getter = property && property.get; - if (!getter && arguments.length === 2) { + var setter = property && property.set; + if ((!getter || setter) && arguments.length === 2) { val = obj[key]; } - var setter = property && property.set; var childOb = !shallow && observe(val); Object.defineProperty(obj, key, { @@ -11393,6 +11423,8 @@ function defineReactive ( if ("development" !== 'production' && customSetter) { customSetter(); } + // #7981: for accessor properties without setter + if (getter && !setter) { return } if (setter) { setter.call(obj, newVal); } else { @@ -11436,7 +11468,7 @@ function set (target, key, val) { target[key] = val; return val } - defineReactive(ob.value, key, val); + defineReactive$$1(ob.value, key, val); ob.dep.notify(); return val } @@ -11523,7 +11555,11 @@ function mergeData (to, from) { fromVal = from[key]; if (!hasOwn(to, key)) { set(to, key, fromVal); - } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { + } else if ( + toVal !== fromVal && + isPlainObject(toVal) && + isPlainObject(fromVal) + ) { mergeData(toVal, fromVal); } } @@ -11846,15 +11882,22 @@ function mergeOptions ( normalizeProps(child, vm); normalizeInject(child, vm); normalizeDirectives(child); - var extendsFrom = child.extends; - if (extendsFrom) { - parent = mergeOptions(parent, extendsFrom, vm); - } - if (child.mixins) { - for (var i = 0, l = child.mixins.length; i < l; i++) { - parent = mergeOptions(parent, child.mixins[i], vm); + + // Apply extends and mixins on the child options, + // but only if it is a raw options object that isn't + // the result of another mergeOptions call. + // Only merged options has the _base property. + if (!child._base) { + if (child.extends) { + parent = mergeOptions(parent, child.extends, vm); + } + if (child.mixins) { + for (var i = 0, l = child.mixins.length; i < l; i++) { + parent = mergeOptions(parent, child.mixins[i], vm); + } } } + var options = {}; var key; for (key in parent) { @@ -11907,6 +11950,8 @@ function resolveAsset ( /* */ + + function validateProp ( key, propOptions, @@ -12014,11 +12059,10 @@ function assertProp ( valid = assertedType.valid; } } + if (!valid) { warn( - "Invalid prop: type check failed for prop \"" + name + "\"." + - " Expected " + (expectedTypes.map(capitalize).join(', ')) + - ", got " + (toRawType(value)) + ".", + getInvalidTypeMessage(name, value, expectedTypes), vm ); return @@ -12085,6 +12129,49 @@ function getTypeIndex (type, expectedTypes) { return -1 } +function getInvalidTypeMessage (name, value, expectedTypes) { + var message = "Invalid prop: type check failed for prop \"" + name + "\"." + + " Expected " + (expectedTypes.map(capitalize).join(', ')); + var expectedType = expectedTypes[0]; + var receivedType = toRawType(value); + var expectedValue = styleValue(value, expectedType); + var receivedValue = styleValue(value, receivedType); + // check if we need to specify expected value + if (expectedTypes.length === 1 && + isExplicable(expectedType) && + !isBoolean(expectedType, receivedType)) { + message += " with value " + expectedValue; + } + message += ", got " + receivedType + " "; + // check if we need to specify received value + if (isExplicable(receivedType)) { + message += "with value " + receivedValue + "."; + } + return message +} + +function styleValue (value, type) { + if (type === 'String') { + return ("\"" + value + "\"") + } else if (type === 'Number') { + return ("" + (Number(value))) + } else { + return ("" + value) + } +} + +function isExplicable (value) { + var explicitTypes = ['string', 'number', 'boolean']; + return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; }) +} + +function isBoolean () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; }) +} + /* */ function handleError (err, vm, info) { @@ -12131,7 +12218,6 @@ function logError (err, vm, info) { } /* */ -/* globals MessageChannel */ var callbacks = []; var pending = false; @@ -12209,9 +12295,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) { function withMacroTask (fn) { return fn._withTask || (fn._withTask = function () { useMacroTask = true; - var res = fn.apply(null, arguments); - useMacroTask = false; - return res + try { + return fn.apply(null, arguments) + } finally { + useMacroTask = false; + } }) } @@ -12292,6 +12380,16 @@ if (true) { ); }; + var warnReservedPrefix = function (target, key) { + warn( + "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " + + 'properties starting with "$" or "_" are not proxied in the Vue instance to ' + + 'prevent conflicts with Vue internals' + + 'See: https://vuejs.org/v2/api/#data', + target + ); + }; + var hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy); @@ -12313,9 +12411,11 @@ if (true) { var hasHandler = { has: function has (target, key) { var has = key in target; - var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; + var isAllowed = allowedGlobals(key) || + (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data)); if (!has && !isAllowed) { - warnNonPresent(target, key); + if (key in target.$data) { warnReservedPrefix(target, key); } + else { warnNonPresent(target, key); } } return has || !isAllowed } @@ -12324,7 +12424,8 @@ if (true) { var getHandler = { get: function get (target, key) { if (typeof key === 'string' && !(key in target)) { - warnNonPresent(target, key); + if (key in target.$data) { warnReservedPrefix(target, key); } + else { warnNonPresent(target, key); } } return target[key] } @@ -12422,14 +12523,14 @@ function updateListeners ( oldOn, add, remove$$1, + createOnceHandler, vm ) { - var name, def, cur, old, event; + var name, def$$1, cur, old, event; for (name in on) { - def = cur = on[name]; + def$$1 = cur = on[name]; old = oldOn[name]; event = normalizeEvent(name); - /* istanbul ignore if */ if (isUndef(cur)) { "development" !== 'production' && warn( "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), @@ -12439,7 +12540,10 @@ function updateListeners ( if (isUndef(cur.fns)) { cur = on[name] = createFnInvoker(cur); } - add(event.name, cur, event.once, event.capture, event.passive, event.params); + if (isTrue(event.once)) { + cur = on[name] = createOnceHandler(event.name, cur, event.capture); + } + add(event.name, cur, event.capture, event.passive, event.params); } else if (cur !== old) { old.fns = cur; on[name] = old; @@ -12694,10 +12798,14 @@ function resolveAsyncComponent ( var contexts = factory.contexts = [context]; var sync = true; - var forceRender = function () { + var forceRender = function (renderCompleted) { for (var i = 0, l = contexts.length; i < l; i++) { contexts[i].$forceUpdate(); } + + if (renderCompleted) { + contexts.length = 0; + } }; var resolve = once(function (res) { @@ -12706,7 +12814,7 @@ function resolveAsyncComponent ( // invoke callbacks only if this is not a synchronous resolve // (async resolves are shimmed as synchronous during SSR) if (!sync) { - forceRender(); + forceRender(true); } }); @@ -12717,7 +12825,7 @@ function resolveAsyncComponent ( ); if (isDef(factory.errorComp)) { factory.error = true; - forceRender(); + forceRender(true); } }); @@ -12744,7 +12852,7 @@ function resolveAsyncComponent ( setTimeout(function () { if (isUndef(factory.resolved) && isUndef(factory.error)) { factory.loading = true; - forceRender(); + forceRender(false); } }, res.delay || 200); } @@ -12807,37 +12915,41 @@ function initEvents (vm) { var target; -function add (event, fn, once) { - if (once) { - target.$once(event, fn); - } else { - target.$on(event, fn); - } +function add (event, fn) { + target.$on(event, fn); } function remove$1 (event, fn) { target.$off(event, fn); } +function createOnceHandler (event, fn) { + var _target = target; + return function onceHandler () { + var res = fn.apply(null, arguments); + if (res !== null) { + _target.$off(event, onceHandler); + } + } +} + function updateComponentListeners ( vm, listeners, oldListeners ) { target = vm; - updateListeners(listeners, oldListeners || {}, add, remove$1, vm); + updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm); target = undefined; } function eventsMixin (Vue) { var hookRE = /^hook:/; Vue.prototype.$on = function (event, fn) { - var this$1 = this; - var vm = this; if (Array.isArray(event)) { for (var i = 0, l = event.length; i < l; i++) { - this$1.$on(event[i], fn); + vm.$on(event[i], fn); } } else { (vm._events[event] || (vm._events[event] = [])).push(fn); @@ -12862,8 +12974,6 @@ function eventsMixin (Vue) { }; Vue.prototype.$off = function (event, fn) { - var this$1 = this; - var vm = this; // all if (!arguments.length) { @@ -12873,7 +12983,7 @@ function eventsMixin (Vue) { // array of events if (Array.isArray(event)) { for (var i = 0, l = event.length; i < l; i++) { - this$1.$off(event[i], fn); + vm.$off(event[i], fn); } return vm } @@ -13002,6 +13112,14 @@ function resolveScopedSlots ( var activeInstance = null; var isUpdatingChildComponent = false; +function setActiveInstance(vm) { + var prevActiveInstance = activeInstance; + activeInstance = vm; + return function () { + activeInstance = prevActiveInstance; + } +} + function initLifecycle (vm) { var options = vm.$options; @@ -13031,31 +13149,20 @@ function initLifecycle (vm) { function lifecycleMixin (Vue) { Vue.prototype._update = function (vnode, hydrating) { var vm = this; - if (vm._isMounted) { - callHook(vm, 'beforeUpdate'); - } var prevEl = vm.$el; var prevVnode = vm._vnode; - var prevActiveInstance = activeInstance; - activeInstance = vm; + var restoreActiveInstance = setActiveInstance(vm); vm._vnode = vnode; // Vue.prototype.__patch__ is injected in entry points // based on the rendering backend used. if (!prevVnode) { // initial render - vm.$el = vm.__patch__( - vm.$el, vnode, hydrating, false /* removeOnly */, - vm.$options._parentElm, - vm.$options._refElm - ); - // no need for the ref nodes after initial patch - // this prevents keeping a detached DOM tree in memory (#5851) - vm.$options._parentElm = vm.$options._refElm = null; + vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */); } else { // updates vm.$el = vm.__patch__(prevVnode, vnode); } - activeInstance = prevActiveInstance; + restoreActiveInstance(); // update __vue__ reference if (prevEl) { prevEl.__vue__ = null; @@ -13178,7 +13285,13 @@ function mountComponent ( // we set this to vm._watcher inside the watcher's constructor // since the watcher's initial patch may call $forceUpdate (e.g. inside child // component's mounted hook), which relies on vm._watcher being already defined - new Watcher(vm, updateComponent, noop, null, true /* isRenderWatcher */); + new Watcher(vm, updateComponent, noop, { + before: function before () { + if (vm._isMounted && !vm._isDestroyed) { + callHook(vm, 'beforeUpdate'); + } + } + }, true /* isRenderWatcher */); hydrating = false; // manually mounted instance, call mounted on self @@ -13318,7 +13431,6 @@ function callHook (vm, hook) { /* */ - var MAX_UPDATE_COUNT = 100; var queue = []; @@ -13362,6 +13474,9 @@ function flushSchedulerQueue () { // as we run existing watchers for (index = 0; index < queue.length; index++) { watcher = queue[index]; + if (watcher.before) { + watcher.before(); + } id = watcher.id; has[id] = null; watcher.run(); @@ -13404,7 +13519,7 @@ function callUpdatedHooks (queue) { while (i--) { var watcher = queue[i]; var vm = watcher.vm; - if (vm._watcher === watcher && vm._isMounted) { + if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) { callHook(vm, 'updated'); } } @@ -13451,6 +13566,11 @@ function queueWatcher (watcher) { // queue the flush if (!waiting) { waiting = true; + + if ("development" !== 'production' && !config.async) { + flushSchedulerQueue(); + return + } nextTick(flushSchedulerQueue); } } @@ -13458,6 +13578,8 @@ function queueWatcher (watcher) { /* */ + + var uid$1 = 0; /** @@ -13483,6 +13605,7 @@ var Watcher = function Watcher ( this.user = !!options.user; this.lazy = !!options.lazy; this.sync = !!options.sync; + this.before = options.before; } else { this.deep = this.user = this.lazy = this.sync = false; } @@ -13503,7 +13626,7 @@ var Watcher = function Watcher ( } else { this.getter = parsePath(expOrFn); if (!this.getter) { - this.getter = function () {}; + this.getter = noop; "development" !== 'production' && warn( "Failed watching path: \"" + expOrFn + "\" " + 'Watcher only accepts simple dot-delimited paths. ' + @@ -13562,13 +13685,11 @@ Watcher.prototype.addDep = function addDep (dep) { * 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); + var dep = this.deps[i]; + if (!this.newDepIds.has(dep.id)) { + dep.removeSub(this); } } var tmp = this.depIds; @@ -13640,11 +13761,9 @@ Watcher.prototype.evaluate = function evaluate () { * Depend on all deps collected by this watcher. */ Watcher.prototype.depend = function depend () { - var this$1 = this; - var i = this.deps.length; while (i--) { - this$1.deps[i].depend(); + this.deps[i].depend(); } }; @@ -13652,8 +13771,6 @@ Watcher.prototype.depend = function depend () { * 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 @@ -13663,7 +13780,7 @@ Watcher.prototype.teardown = function teardown () { } var i = this.deps.length; while (i--) { - this$1.deps[i].removeSub(this$1); + this.deps[i].removeSub(this); } this.active = false; } @@ -13728,8 +13845,8 @@ function initProps (vm, propsOptions) { vm ); } - defineReactive(props, key, value, function () { - if (vm.$parent && !isUpdatingChildComponent) { + defineReactive$$1(props, key, value, function () { + if (!isRoot && !isUpdatingChildComponent) { warn( "Avoid mutating a prop directly since the value will be " + "overwritten whenever the parent component re-renders. " + @@ -13740,7 +13857,7 @@ function initProps (vm, propsOptions) { } }); } else { - defineReactive(props, key, value); + defineReactive$$1(props, key, value); } // static props are already proxied on the component's prototype // during Vue.extend(). We only need to proxy props defined at @@ -13861,17 +13978,15 @@ function defineComputed ( if (typeof userDef === 'function') { sharedPropertyDefinition.get = shouldCache ? createComputedGetter(key) - : userDef; + : createGetterInvoker(userDef); sharedPropertyDefinition.set = noop; } else { sharedPropertyDefinition.get = userDef.get ? shouldCache && userDef.cache !== false ? createComputedGetter(key) - : userDef.get - : noop; - sharedPropertyDefinition.set = userDef.set - ? userDef.set + : createGetterInvoker(userDef.get) : noop; + sharedPropertyDefinition.set = userDef.set || noop; } if ("development" !== 'production' && sharedPropertyDefinition.set === noop) { @@ -13900,13 +14015,19 @@ function createComputedGetter (key) { } } +function createGetterInvoker(fn) { + return function computedGetter () { + return fn.call(this, this) + } +} + function initMethods (vm, methods) { var props = vm.$options.props; for (var key in methods) { if (true) { - if (methods[key] == null) { + if (typeof methods[key] !== 'function') { warn( - "Method \"" + key + "\" has an undefined value in the component definition. " + + "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " + "Did you reference the function correctly?", vm ); @@ -13924,7 +14045,7 @@ function initMethods (vm, methods) { ); } } - vm[key] = methods[key] == null ? noop : bind(methods[key], vm); + vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm); } } @@ -13966,7 +14087,7 @@ function stateMixin (Vue) { var propsDef = {}; propsDef.get = function () { return this._props }; if (true) { - dataDef.set = function (newData) { + dataDef.set = function () { warn( 'Avoid replacing instance root $data. ' + 'Use nested data properties instead.', @@ -13996,7 +14117,11 @@ function stateMixin (Vue) { options.user = true; var watcher = new Watcher(vm, expOrFn, cb, options); if (options.immediate) { - cb.call(vm, watcher.value); + try { + cb.call(vm, watcher.value); + } catch (error) { + handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\"")); + } } return function unwatchFn () { watcher.teardown(); @@ -14022,7 +14147,7 @@ function initInjections (vm) { Object.keys(result).forEach(function (key) { /* istanbul ignore else */ if (true) { - defineReactive(vm, key, result[key], function () { + defineReactive$$1(vm, key, result[key], function () { warn( "Avoid mutating an injected value directly since the changes will be " + "overwritten whenever the provided component re-renders. " + @@ -14031,7 +14156,7 @@ function initInjections (vm) { ); }); } else { - defineReactive(vm, key, result[key]); + defineReactive$$1(vm, key, result[key]); } }); toggleObserving(true); @@ -14103,9 +14228,10 @@ function renderList ( ret[i] = render(val[key], key, i); } } - if (isDef(ret)) { - (ret)._isVList = true; + if (!isDef(ret)) { + ret = []; } + (ret)._isVList = true; return ret } @@ -14135,19 +14261,7 @@ function renderSlot ( } nodes = scopedSlotFn(props) || fallback; } else { - var slotNodes = this.$slots[name]; - // warn duplicate slot usage - if (slotNodes) { - if ("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; - } - nodes = slotNodes || fallback; + nodes = this.$slots[name] || fallback; } var target = props && props.slot; @@ -14235,12 +14349,13 @@ function bindObjectProps ( ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {}); } - if (!(key in hash)) { + var camelizedKey = camelize(key); + if (!(key in hash) && !(camelizedKey in hash)) { hash[key] = value[key]; if (isSync) { var on = data.on || (data.on = {}); - on[("update:" + key)] = function ($event) { + on[("update:" + camelizedKey)] = function ($event) { value[key] = $event; }; } @@ -14446,24 +14561,27 @@ function createFunctionalComponent ( var vnode = options.render.call(null, renderContext._c, renderContext); if (vnode instanceof VNode) { - return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options) + return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext) } else if (Array.isArray(vnode)) { var vnodes = normalizeChildren(vnode) || []; var res = new Array(vnodes.length); for (var i = 0; i < vnodes.length; i++) { - res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options); + res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext); } return res } } -function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) { +function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) { // #7817 clone node before setting fnContext, otherwise if the node is reused // (e.g. it was from a cached normal slot) the fnContext causes named slots // that should not be matched to match. var clone = cloneVNode(vnode); clone.fnContext = contextVm; clone.fnOptions = options; + if (true) { + (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext; + } if (data.slot) { (clone.data || (clone.data = {})).slot = data.slot; } @@ -14478,33 +14596,15 @@ function mergeProps (to, from) { /* */ - - - -// Register the component hook to weex native render engine. -// The hook will be triggered by native, not javascript. - - -// Updates the state of the component to weex native render engine. - /* */ -// https://github.com/Hanks10100/weex-native-directive/tree/master/component - -// listening on native callback - /* */ /* */ // inline hooks to be invoked on component VNodes during patch var componentVNodeHooks = { - init: function init ( - vnode, - hydrating, - parentElm, - refElm - ) { + init: function init (vnode, hydrating) { if ( vnode.componentInstance && !vnode.componentInstance._isDestroyed && @@ -14516,9 +14616,7 @@ var componentVNodeHooks = { } else { var child = vnode.componentInstance = createComponentInstanceForVnode( vnode, - activeInstance, - parentElm, - refElm + activeInstance ); child.$mount(hydrating ? vnode.elm : undefined, hydrating); } @@ -14667,25 +14765,17 @@ function createComponent ( asyncFactory ); - // Weex specific: invoke recycle-list optimized @render function for - // extracting cell-slot template. - // https://github.com/Hanks10100/weex-native-directive/tree/master/component - /* istanbul ignore if */ return vnode } function createComponentInstanceForVnode ( vnode, // we know it's MountedComponentVNode but flow doesn't - parent, // activeInstance in lifecycle state - parentElm, - refElm + parent // activeInstance in lifecycle state ) { var options = { _isComponent: true, - parent: parent, _parentVnode: vnode, - _parentElm: parentElm || null, - _refElm: refElm || null + parent: parent }; // check inline-template render functions var inlineTemplate = vnode.data.inlineTemplate; @@ -14700,20 +14790,43 @@ function installComponentHooks (data) { var hooks = data.hook || (data.hook = {}); for (var i = 0; i < hooksToMerge.length; i++) { var key = hooksToMerge[i]; - hooks[key] = componentVNodeHooks[key]; + var existing = hooks[key]; + var toMerge = componentVNodeHooks[key]; + if (existing !== toMerge && !(existing && existing._merged)) { + hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge; + } } } +function mergeHook$1 (f1, f2) { + var merged = function (a, b) { + // flow complains about extra args which is why we use any + f1(a, b); + f2(a, b); + }; + merged._merged = true; + return merged +} + // transform component v-model info (value and callback) into // prop and event handler respectively. function transformModel (options, data) { var prop = (options.model && options.model.prop) || 'value'; - var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value; + var event = (options.model && options.model.event) || 'input' + ;(data.props || (data.props = {}))[prop] = data.model.value; var on = data.on || (data.on = {}); - if (isDef(on[event])) { - on[event] = [data.model.callback].concat(on[event]); + var existing = on[event]; + var callback = data.model.callback; + if (isDef(existing)) { + if ( + Array.isArray(existing) + ? existing.indexOf(callback) === -1 + : existing !== callback + ) { + on[event] = [callback].concat(existing); + } } else { - on[event] = data.model.callback; + on[event] = callback; } } @@ -14801,7 +14914,7 @@ function _createElement ( config.parsePlatformTagName(tag), data, children, undefined, undefined, context ); - } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { + } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { // component vnode = createComponent(Ctor, data, context, children, tag); } else { @@ -14883,15 +14996,15 @@ function initRender (vm) { /* istanbul ignore else */ if (true) { - defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () { + defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () { !isUpdatingChildComponent && warn("$attrs is readonly.", vm); }, true); - defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () { + defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () { !isUpdatingChildComponent && warn("$listeners is readonly.", vm); }, true); } else { - defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true); - defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true); + defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true); + defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true); } } @@ -14909,14 +15022,6 @@ function renderMixin (Vue) { var render = ref.render; var _parentVnode = ref._parentVnode; - // reset _rendered flag on slots for duplicate slot check - if (true) { - for (var key in vm.$slots) { - // $flow-disable-line - vm.$slots[key]._rendered = false; - } - } - if (_parentVnode) { vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject; } @@ -14933,15 +15038,11 @@ function renderMixin (Vue) { // return error render result, // or previous vnode to prevent render error causing blank component /* istanbul ignore else */ - if (true) { - if (vm.$options.renderError) { - try { - vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); - } catch (e) { - handleError(e, vm, "renderError"); - vnode = vm._vnode; - } - } else { + if ("development" !== 'production' && vm.$options.renderError) { + try { + vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); + } catch (e) { + handleError(e, vm, "renderError"); vnode = vm._vnode; } } else { @@ -15034,8 +15135,6 @@ function initInternalComponent (vm, options) { var parentVnode = options._parentVnode; opts.parent = options.parent; opts._parentVnode = parentVnode; - opts._parentElm = options._parentElm; - opts._refElm = options._refElm; var vnodeComponentOptions = parentVnode.componentOptions; opts.propsData = vnodeComponentOptions.propsData; @@ -15278,6 +15377,8 @@ function initAssetRegisters (Vue) { /* */ + + function getComponentName (opts) { return opts && (opts.Ctor.options.name || opts.tag) } @@ -15341,10 +15442,8 @@ var KeepAlive = { }, destroyed: function destroyed () { - var this$1 = this; - - for (var key in this$1.cache) { - pruneCacheEntry(this$1.cache, key, this$1.keys); + for (var key in this.cache) { + pruneCacheEntry(this.cache, key, this.keys); } }, @@ -15404,11 +15503,11 @@ var KeepAlive = { } return vnode || (slot && slot[0]) } -} +}; var builtInComponents = { KeepAlive: KeepAlive -} +}; /* */ @@ -15432,7 +15531,7 @@ function initGlobalAPI (Vue) { warn: warn, extend: extend, mergeOptions: mergeOptions, - defineReactive: defineReactive + defineReactive: defineReactive$$1 }; Vue.set = set; @@ -15474,7 +15573,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', { value: FunctionalRenderContext }); -Vue.version = '2.5.17'; +Vue.version = '2.5.21'; /* */ @@ -15752,20 +15851,19 @@ function setStyleScope (node, scopeId) { node.setAttribute(scopeId, ''); } - -var nodeOps = Object.freeze({ - createElement: createElement$1, - createElementNS: createElementNS, - createTextNode: createTextNode, - createComment: createComment, - insertBefore: insertBefore, - removeChild: removeChild, - appendChild: appendChild, - parentNode: parentNode, - nextSibling: nextSibling, - tagName: tagName, - setTextContent: setTextContent, - setStyleScope: setStyleScope +var nodeOps = /*#__PURE__*/Object.freeze({ + createElement: createElement$1, + createElementNS: createElementNS, + createTextNode: createTextNode, + createComment: createComment, + insertBefore: insertBefore, + removeChild: removeChild, + appendChild: appendChild, + parentNode: parentNode, + nextSibling: nextSibling, + tagName: tagName, + setTextContent: setTextContent, + setStyleScope: setStyleScope }); /* */ @@ -15783,7 +15881,7 @@ var ref = { destroy: function destroy (vnode) { registerRef(vnode, true); } -} +}; function registerRef (vnode, isRemoval) { var key = vnode.data.ref; @@ -15884,13 +15982,13 @@ function createPatchFunction (backend) { } function createRmCb (childElm, listeners) { - function remove () { - if (--remove.listeners === 0) { + function remove$$1 () { + if (--remove$$1.listeners === 0) { removeNode(childElm); } } - remove.listeners = listeners; - return remove + remove$$1.listeners = listeners; + return remove$$1 } function removeNode (el) { @@ -15991,7 +16089,7 @@ function createPatchFunction (backend) { if (isDef(i)) { var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; if (isDef(i = i.hook) && isDef(i = i.init)) { - i(vnode, false /* hydrating */, parentElm, refElm); + i(vnode, false /* hydrating */); } // after calling the init hook, if the vnode is a child component // it should've created a child instance and mounted it. the child @@ -15999,6 +16097,7 @@ function createPatchFunction (backend) { // in that case we can just return the element and be done. if (isDef(vnode.componentInstance)) { initComponent(vnode, insertedVnodeQueue); + insert(parentElm, vnode.elm, refElm); if (isTrue(isReactivated)) { reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); } @@ -16050,7 +16149,7 @@ function createPatchFunction (backend) { function insert (parent, elm, ref$$1) { if (isDef(parent)) { if (isDef(ref$$1)) { - if (ref$$1.parentNode === parent) { + if (nodeOps.parentNode(ref$$1) === parent) { nodeOps.insertBefore(parent, elm, ref$$1); } } else { @@ -16205,20 +16304,20 @@ function createPatchFunction (backend) { } else if (isUndef(oldEndVnode)) { oldEndVnode = oldCh[--oldEndIdx]; } else if (sameVnode(oldStartVnode, newStartVnode)) { - patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue); + patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); oldStartVnode = oldCh[++oldStartIdx]; newStartVnode = newCh[++newStartIdx]; } else if (sameVnode(oldEndVnode, newEndVnode)) { - patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue); + patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); oldEndVnode = oldCh[--oldEndIdx]; newEndVnode = newCh[--newEndIdx]; } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right - patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue); + patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); oldStartVnode = oldCh[++oldStartIdx]; newEndVnode = newCh[--newEndIdx]; } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left - patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue); + patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); oldEndVnode = oldCh[--oldEndIdx]; newStartVnode = newCh[++newStartIdx]; @@ -16232,7 +16331,7 @@ function createPatchFunction (backend) { } else { vnodeToMove = oldCh[idxInOld]; if (sameVnode(vnodeToMove, newStartVnode)) { - patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue); + patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); oldCh[idxInOld] = undefined; canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); } else { @@ -16276,11 +16375,23 @@ function createPatchFunction (backend) { } } - function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) { + function patchVnode ( + oldVnode, + vnode, + insertedVnodeQueue, + ownerArray, + index, + removeOnly + ) { if (oldVnode === vnode) { return } + if (isDef(vnode.elm) && isDef(ownerArray)) { + // clone reused vnode + vnode = ownerArray[index] = cloneVNode(vnode); + } + var elm = vnode.elm = oldVnode.elm; if (isTrue(oldVnode.isAsyncPlaceholder)) { @@ -16321,6 +16432,9 @@ function createPatchFunction (backend) { if (isDef(oldCh) && isDef(ch)) { if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } } else if (isDef(ch)) { + if (true) { + checkDuplicateKeys(ch); + } if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); } else if (isDef(oldCh)) { @@ -16462,7 +16576,7 @@ function createPatchFunction (backend) { } } - return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) { + return function patch (oldVnode, vnode, hydrating, removeOnly) { if (isUndef(vnode)) { if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); } return @@ -16474,12 +16588,12 @@ function createPatchFunction (backend) { if (isUndef(oldVnode)) { // empty mount (likely as component), create new root element isInitialPatch = true; - createElm(vnode, insertedVnodeQueue, parentElm, refElm); + createElm(vnode, insertedVnodeQueue); } else { var isRealElement = isDef(oldVnode.nodeType); if (!isRealElement && sameVnode(oldVnode, vnode)) { // patch existing root node - patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly); + patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly); } else { if (isRealElement) { // mounting to a real element @@ -16510,7 +16624,7 @@ function createPatchFunction (backend) { // replacing existing element var oldElm = oldVnode.elm; - var parentElm$1 = nodeOps.parentNode(oldElm); + var parentElm = nodeOps.parentNode(oldElm); // create new node createElm( @@ -16519,7 +16633,7 @@ function createPatchFunction (backend) { // extremely rare edge case: do not insert if old element is in a // leaving transition. Only happens when combining transition + // keep-alive + HOCs. (#4590) - oldElm._leaveCb ? null : parentElm$1, + oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm) ); @@ -16554,8 +16668,8 @@ function createPatchFunction (backend) { } // destroy old node - if (isDef(parentElm$1)) { - removeVnodes(parentElm$1, [oldVnode], 0, 0); + if (isDef(parentElm)) { + removeVnodes(parentElm, [oldVnode], 0, 0); } else if (isDef(oldVnode.tag)) { invokeDestroyHook(oldVnode); } @@ -16575,7 +16689,7 @@ var directives = { destroy: function unbindDirectives (vnode) { updateDirectives(vnode, emptyNode); } -} +}; function updateDirectives (oldVnode, vnode) { if (oldVnode.data.directives || vnode.data.directives) { @@ -16686,7 +16800,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { var baseModules = [ ref, directives -] +]; /* */ @@ -16770,7 +16884,7 @@ function baseSetAttr (el, key, value) { /* istanbul ignore if */ if ( isIE && !isIE9 && - el.tagName === 'TEXTAREA' && + (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') && key === 'placeholder' && !el.__ieph ) { var blocker = function (e) { @@ -16788,7 +16902,7 @@ function baseSetAttr (el, key, value) { var attrs = { create: updateAttrs, update: updateAttrs -} +}; /* */ @@ -16826,7 +16940,7 @@ function updateClass (oldVnode, vnode) { var klass = { create: updateClass, update: updateClass -} +}; /* */ @@ -16990,6 +17104,18 @@ function addHandler ( ); } + // normalize click.right and click.middle since they don't actually fire + // this is technically browser-specific, but at least for now browsers are + // the only target envs that have right/middle clicks. + if (name === 'click') { + if (modifiers.right) { + name = 'contextmenu'; + delete modifiers.right; + } else if (modifiers.middle) { + name = 'mouseup'; + } + } + // check capture modifier if (modifiers.capture) { delete modifiers.capture; @@ -17005,18 +17131,6 @@ function addHandler ( name = '&' + name; // mark the event as passive } - // normalize click.right and click.middle since they don't actually fire - // this is technically browser-specific, but at least for now browsers are - // the only target envs that have right/middle clicks. - if (name === 'click') { - if (modifiers.right) { - name = 'contextmenu'; - delete modifiers.right; - } else if (modifiers.middle) { - name = 'mouseup'; - } - } - var events; if (modifiers.native) { delete modifiers.native; @@ -17117,7 +17231,7 @@ function genComponentModel ( el.model = { value: ("(" + value + ")"), - expression: ("\"" + value + "\""), + expression: JSON.stringify(value), callback: ("function (" + baseValueExpression + ") {" + assignment + "}") }; } @@ -17152,12 +17266,7 @@ function genAssignmentCode ( * */ -var len; -var str; -var chr; -var index$1; -var expressionPos; -var expressionEndPos; +var len, str, chr, index$1, expressionPos, expressionEndPos; @@ -17438,7 +17547,7 @@ function normalizeEvents (on) { var target$1; -function createOnceHandler (handler, event, capture) { +function createOnceHandler$1 (event, handler, capture) { var _target = target$1; // save current target element in closure return function onceHandler () { var res = handler.apply(null, arguments); @@ -17451,12 +17560,10 @@ function createOnceHandler (handler, event, capture) { function add$1 ( event, handler, - once$$1, capture, passive ) { handler = withMacroTask(handler); - if (once$$1) { handler = createOnceHandler(handler, event, capture); } target$1.addEventListener( event, handler, @@ -17487,14 +17594,14 @@ function updateDOMListeners (oldVnode, vnode) { var oldOn = oldVnode.data.on || {}; target$1 = vnode.elm; normalizeEvents(on); - updateListeners(on, oldOn, add$1, remove$2, vnode.context); + updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context); target$1 = undefined; } var events = { create: updateDOMListeners, update: updateDOMListeners -} +}; /* */ @@ -17588,7 +17695,7 @@ function isDirtyWithModifiers (elm, newVal) { var domProps = { create: updateDOMProps, update: updateDOMProps -} +}; /* */ @@ -17749,10 +17856,12 @@ function updateStyle (oldVnode, vnode) { var style = { create: updateStyle, update: updateStyle -} +}; /* */ +var whitespaceRE = /\s+/; + /** * Add class with compatibility for SVG since classList is not supported on * SVG elements in IE @@ -17766,7 +17875,7 @@ function addClass (el, cls) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { - cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); + cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); }); } else { el.classList.add(cls); } @@ -17791,7 +17900,7 @@ function removeClass (el, cls) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { - cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); + cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); }); } else { el.classList.remove(cls); } @@ -17815,20 +17924,20 @@ function removeClass (el, cls) { /* */ -function resolveTransition (def) { - if (!def) { +function resolveTransition (def$$1) { + if (!def$$1) { return } /* istanbul ignore else */ - if (typeof def === 'object') { + if (typeof def$$1 === 'object') { var res = {}; - if (def.css !== false) { - extend(res, autoCssTransition(def.name || 'v')); + if (def$$1.css !== false) { + extend(res, autoCssTransition(def$$1.name || 'v')); } - extend(res, def); + extend(res, def$$1); return res - } else if (typeof def === 'string') { - return autoCssTransition(def) + } else if (typeof def$$1 === 'string') { + return autoCssTransition(def$$1) } } @@ -17931,11 +18040,12 @@ var transformRE = /\b(transform|all)(,|$)/; function getTransitionInfo (el, expectedType) { var styles = window.getComputedStyle(el); - var transitionDelays = styles[transitionProp + 'Delay'].split(', '); - var transitionDurations = styles[transitionProp + 'Duration'].split(', '); + // JSDOM may return undefined for transition properties + var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', '); + var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', '); var transitionTimeout = getTimeout(transitionDelays, transitionDurations); - var animationDelays = styles[animationProp + 'Delay'].split(', '); - var animationDurations = styles[animationProp + 'Duration'].split(', '); + var animationDelays = (styles[animationProp + 'Delay'] || '').split(', '); + var animationDurations = (styles[animationProp + 'Duration'] || '').split(', '); var animationTimeout = getTimeout(animationDelays, animationDurations); var type; @@ -17989,8 +18099,12 @@ function getTimeout (delays, durations) { })) } +// Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers +// in a locale-dependent way, using a comma instead of a dot. +// If comma is not replaced with a dot, the input will be rounded down (i.e. acting +// as a floor function) causing unexpected behaviors function toMs (s) { - return Number(s.slice(0, -1)) * 1000 + return Number(s.slice(0, -1).replace(',', '.')) * 1000 } /* */ @@ -18222,7 +18336,7 @@ function leave (vnode, rm) { return } // record leaving element - if (!vnode.data.show) { + if (!vnode.data.show && el.parentNode) { (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode; } beforeLeave && beforeLeave(el); @@ -18311,7 +18425,7 @@ var transition = inBrowser ? { rm(); } } -} : {} +} : {}; var platformModules = [ attrs, @@ -18320,7 +18434,7 @@ var platformModules = [ domProps, style, transition -] +]; /* */ @@ -18531,18 +18645,15 @@ var show = { el.style.display = el.__vOriginalDisplay; } } -} +}; var platformDirectives = { model: directive, show: show -} +}; /* */ -// Provides transition support for a single element/component. -// supports transition mode (out-in / in-out) - var transitionProps = { name: String, appear: Boolean, @@ -18608,6 +18719,10 @@ function isSameChild (child, oldChild) { return oldChild.key === child.key && oldChild.tag === child.tag } +var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); }; + +var isVShowDirective = function (d) { return d.name === 'show'; }; + var Transition = { name: 'transition', props: transitionProps, @@ -18622,7 +18737,7 @@ var Transition = { } // filter out text nodes (possible whitespaces) - children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); }); + children = children.filter(isNotTextNode); /* istanbul ignore if */ if (!children.length) { return @@ -18687,7 +18802,7 @@ var Transition = { // mark v-show // so that the transition module can hand over the control to the directive - if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) { + if (child.data.directives && child.data.directives.some(isVShowDirective)) { child.data.show = true; } @@ -18725,21 +18840,10 @@ var Transition = { return rawChild } -} +}; /* */ -// Provides transition support for list items. -// supports move transitions using the FLIP technique. - -// Because the vdom's children update algorithm is "unstable" - i.e. -// it doesn't guarantee the relative positioning of removed elements, -// we force transition-group to update its children into two passes: -// in the first pass, we remove all nodes that need to be removed, -// triggering their leaving transition; in the second pass, we insert/move -// into the final desired state. This way in the second pass removed -// nodes will remain where they should be. - var props = extend({ tag: String, moveClass: String @@ -18750,6 +18854,25 @@ delete props.mode; var TransitionGroup = { props: props, + beforeMount: function beforeMount () { + var this$1 = this; + + var update = this._update; + this._update = function (vnode, hydrating) { + var restoreActiveInstance = setActiveInstance(this$1); + // force removing pass + this$1.__patch__( + this$1._vnode, + this$1.kept, + false, // hydrating + true // removeOnly (!important, avoids unnecessary moves) + ); + this$1._vnode = this$1.kept; + restoreActiveInstance(); + update.call(this$1, vnode, hydrating); + }; + }, + render: function render (h) { var tag = this.tag || this.$vnode.data.tag || 'span'; var map = Object.create(null); @@ -18793,17 +18916,6 @@ var TransitionGroup = { return h(tag, null, children) }, - beforeUpdate: function beforeUpdate () { - // force removing pass - this.__patch__( - this._vnode, - this.kept, - false, // hydrating - true // removeOnly (!important, avoids unnecessary moves) - ); - this._vnode = this.kept; - }, - updated: function updated () { var children = this.prevChildren; var moveClass = this.moveClass || ((this.name || 'v') + '-move'); @@ -18829,6 +18941,9 @@ var TransitionGroup = { addTransitionClass(el, moveClass); s.transform = s.WebkitTransform = s.transitionDuration = ''; el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { + if (e && e.target !== el) { + return + } if (!e || /transform$/.test(e.propertyName)) { el.removeEventListener(transitionEndEvent, cb); el._moveCb = null; @@ -18866,7 +18981,7 @@ var TransitionGroup = { return (this._hasMove = info.hasTransform) } } -} +}; function callPendingCbs (c) { /* istanbul ignore if */ @@ -18899,7 +19014,7 @@ function applyTranslation (c) { var platformComponents = { Transition: Transition, TransitionGroup: TransitionGroup -} +}; /* */ @@ -18960,7 +19075,7 @@ if (inBrowser) { /* */ -var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; +var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g; var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; var buildRegex = cached(function (delimiters) { @@ -19046,7 +19161,7 @@ var klass$1 = { staticKeys: ['staticClass'], transformNode: transformNode, genData: genData -} +}; /* */ @@ -19090,7 +19205,7 @@ var style$1 = { staticKeys: ['staticStyle'], transformNode: transformNode$1, genData: genData$1 -} +}; /* */ @@ -19102,7 +19217,7 @@ var he = { decoder.innerHTML = html; return decoder.textContent } -} +}; /* */ @@ -19131,13 +19246,6 @@ var isNonPhrasingTag = makeMap( * Not type-checking this file because it's mostly vendor code. */ -/*! - * HTML Parser By John Resig (ejohn.org) - * Modified by Juriy "kangax" Zaytsev - * Original code by Erik Arvidsson, Mozilla Public License - * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js - */ - // Regular Expressions for parsing tags and attributes var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName @@ -19152,11 +19260,6 @@ var doctype = /^]+>/i; var comment = /^= 0; pos--) { if (stack[pos].lowerCasedTag === lowerCasedTagName) { break @@ -19439,7 +19533,7 @@ function parseHTML (html, options) { var onRE = /^@|^v-on:/; var dirRE = /^v-|^@|^:/; -var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/; +var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; var stripParensRE = /^\(|\)$/g; @@ -19624,7 +19718,8 @@ function parse ( processIfConditions(element, currentParent); } else if (element.slotScope) { // scoped slot currentParent.plain = false; - var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; + var name = element.slotTarget || '"default"' + ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; } else { currentParent.children.push(element); element.parent = currentParent; @@ -19748,8 +19843,20 @@ function processElement (element, options) { function processKey (el) { var exp = getBindingAttr(el, 'key'); if (exp) { - if ("development" !== 'production' && el.tag === 'template') { - warn$2("