Merge pull request #136 from malash/fix/util-extend

Rewrite util.extend to a clone version
This commit is contained in:
Faisal Salman 2016-02-25 10:54:54 +07:00
commit 3a457f9bd9
3 changed files with 9 additions and 21 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") {
@ -801,7 +804,6 @@
ua = uastring; ua = uastring;
return this; return this;
}; };
this.setUA(ua);
return this; return this;
}; };