mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2026-01-03 04:44:42 +03:00
Move properties inside UAItem class into shared prototype
This commit is contained in:
@@ -1191,23 +1191,32 @@
|
||||
}
|
||||
|
||||
function UAItem (itemType, ua, rgxMap, uaCH) {
|
||||
setProps.call(this, [
|
||||
['itemType', itemType],
|
||||
['ua', ua],
|
||||
['uaCH', uaCH],
|
||||
['rgxMap', rgxMap],
|
||||
['data', createIData(this, itemType)]
|
||||
]);
|
||||
return this;
|
||||
}
|
||||
|
||||
this.get = function (prop) {
|
||||
UAItem.prototype.get = function (prop) {
|
||||
if (!prop) return this.data;
|
||||
return this.data.hasOwnProperty(prop) ? this.data[prop] : undefined;
|
||||
};
|
||||
|
||||
this.set = function (prop, val) {
|
||||
UAItem.prototype.set = function (prop, val) {
|
||||
this.data[prop] = val;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setCH = function (ch) {
|
||||
UAItem.prototype.setCH = function (ch) {
|
||||
this.uaCH = ch;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.detectFeature = function () {
|
||||
UAItem.prototype.detectFeature = function () {
|
||||
if (NAVIGATOR && NAVIGATOR.userAgent == this.ua) {
|
||||
switch (this.itemType) {
|
||||
case BROWSER:
|
||||
@@ -1251,7 +1260,7 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
this.parseUA = function () {
|
||||
UAItem.prototype.parseUA = function () {
|
||||
if (this.itemType != RESULT) {
|
||||
rgxMapper.call(this.data, this.ua, this.rgxMap);
|
||||
}
|
||||
@@ -1272,7 +1281,7 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
this.parseCH = function () {
|
||||
UAItem.prototype.parseCH = function () {
|
||||
var uaCH = this.uaCH,
|
||||
rgxMap = this.rgxMap;
|
||||
|
||||
@@ -1374,17 +1383,6 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
setProps.call(this, [
|
||||
['itemType', itemType],
|
||||
['ua', ua],
|
||||
['uaCH', uaCH],
|
||||
['rgxMap', rgxMap],
|
||||
['data', createIData(this, itemType)]
|
||||
]);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function UAParser (ua, extensions, headers) {
|
||||
|
||||
if (typeof ua === TYPEOF.OBJECT) {
|
||||
|
||||
Reference in New Issue
Block a user