From 18d9974226892fb2d958372847be190e553b5f6e Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Wed, 27 May 2020 17:29:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9Ebefore=E5=92=8Cafter=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + lodash.md | 2 +- src/core/base.js | 6 +++--- src/core/lodash.js | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 5857959e2..d0dbaf2c1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-05) +- 新增BI.after和BI.before方法 - 修复bi.button设置宽度并配置iconCls后,文本很长的情况下显示截断的问题 - 填加bi-user-select-enable和bi-user-select-disable通用类名 - 修复树系列多层半选状态下,勾选祖先节点,后代节点不受影响的问题 diff --git a/lodash.md b/lodash.md index 585e74b43..8eff925dc 100644 --- a/lodash.md +++ b/lodash.md @@ -1 +1 @@ -lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy" \ No newline at end of file +lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after" diff --git a/src/core/base.js b/src/core/base.js index df0c6017a..e073da354 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -109,7 +109,7 @@ if (!_global.BI) { } if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) { innerAttr.shift(); - return BI.extend({}, outerAttr.shift(), {type: null}, item); + return BI.extend({}, outerAttr.shift(), { type: null }, item); } if (item.el) { return BI.extend({}, outerAttr.shift(), item, { @@ -508,7 +508,7 @@ if (!_global.BI) { }, isNull: function (obj) { - return typeof obj === "undefined" || obj === null; + return typeof obj === "undefined" || obj === null; }, isEmptyArray: function (arr) { @@ -660,7 +660,7 @@ if (!_global.BI) { }); // 通用方法 - _.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape"], function (name) { + _.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape", "before", "after"], function (name) { BI[name] = function () { return _[name].apply(_, arguments); }; diff --git a/src/core/lodash.js b/src/core/lodash.js index 39a72d4aa..95d7a53e4 100644 --- a/src/core/lodash.js +++ b/src/core/lodash.js @@ -1,7 +1,7 @@ /** * @license * Lodash (Custom Build) - * Build: `lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"` + * Build: `lodash core plus="debounce,throttle,get,set,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy,before,after"` * Copyright JS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 @@ -6994,6 +6994,42 @@ /*------------------------------------------------------------------------*/ + /** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ + function after(n, func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + /** * Creates a function that invokes `func`, with the `this` binding and arguments * of the created function, while it's called less than `n` times. Subsequent @@ -9824,6 +9860,7 @@ /*------------------------------------------------------------------------*/ // Add methods that return wrapped values in chain sequences. + lodash.after = after; lodash.assignIn = assignIn; lodash.before = before; lodash.bind = bind;