Rewrite util.extend to a clone version

This commit is contained in:
Malash 2015-10-10 14:50:15 +08:00
parent 20ea67ed1d
commit 792dc0246a
3 changed files with 12 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45,12 +45,15 @@
var util = { var util = {
extend : function (regexes, extensions) { extend : function (regexes, extensions) {
for (var i in extensions) { var margedRegexes = {};
if ("browser cpu device engine os".indexOf(i) !== -1 && extensions[i].length % 2 === 0) { for (var i in regexes) {
regexes[i] = extensions[i].concat(regexes[i]); if (extensions[i] && extensions[i].length % 2 === 0) {
margedRegexes[i] = extensions[i].concat(regexes[i]);
} else {
margedRegexes[i] = regexes[i];
} }
} }
return regexes; return margedRegexes;
}, },
has : function (str1, str2) { has : function (str1, str2) {
if (typeof str1 === "string") { if (typeof str1 === "string") {
@ -794,7 +797,6 @@
ua = uastring; ua = uastring;
return this; return this;
}; };
this.setUA(ua);
return this; return this;
}; };