From b16dd92a48fa6edc216050e083657fff2eeb018f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 4 Mar 2014 04:15:15 -0500 Subject: [PATCH] refactor(util) removeStrOneTime, ownRender --- lib/util.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/util.js b/lib/util.js index 0d4d43f3..be55cbec 100644 --- a/lib/util.js +++ b/lib/util.js @@ -513,23 +513,23 @@ * @param pStr * @param pSubStr */ - this.removeStrOneTime = function(pStr, pSubStr) { - var lRet = Util.isString(pStr) && pSubStr; + this.removeStrOneTime = function(str, substr) { + var n, isArray, + isString = Util.isString(str); - if ( lRet ) { - var n = pSubStr.length; + if (isString && substr) { + n = substr.length; + isArray = Util.isArray(substr); - if ( Util.isArray(pSubStr) ) - Util.fori(n, function(i) { - lRet = pStr = pStr.replace(pSubStr[i], ''); - }); + if (!isArray) + str = str.replace(substr, ''); else - lRet = pStr.replace(pSubStr, ''); + Util.fori(n, function(i) { + str = str.replace(substr[i], ''); + }); } - else - lRet = pStr; - return lRet; + return str; }; /** @@ -602,7 +602,7 @@ } expr = firstChar + '.*' + secondChar; - ret = Util.replaceStr(templ, expr, '', notEscape); + ret = Util.replaceStr(ret, expr, '', notEscape); return ret; };