Make upgradeTo an object prototype
Change-Id: Ibdedbc5a57215151f97c5903ac69ba3ce6bab10c
diff --git a/dev/js/src/buttongroup.js b/dev/js/src/buttongroup.js
index dabe710..85c6555 100644
--- a/dev/js/src/buttongroup.js
+++ b/dev/js/src/buttongroup.js
@@ -64,18 +64,6 @@
return false;
},
- /**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (var prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
_insert : function (tag = 'span') {
const span = document.createElement(tag);
diff --git a/dev/js/src/container/container.js b/dev/js/src/container/container.js
index 9b436ca..60bc0d9 100644
--- a/dev/js/src/container/container.js
+++ b/dev/js/src/container/container.js
@@ -54,18 +54,6 @@
},
- /**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
addItem : function (item) {
var cItem = this._containerItemClass.create().upgradeTo(item);
@@ -227,4 +215,4 @@
}
};
-});
\ No newline at end of file
+});
diff --git a/dev/js/src/container/containeritem.js b/dev/js/src/container/containeritem.js
index 10709b8..a9a209b 100644
--- a/dev/js/src/container/containeritem.js
+++ b/dev/js/src/container/containeritem.js
@@ -18,19 +18,6 @@
},
/**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
- /**
* Check or set if the item is active
*
* @param {boolean|null} State of activity
@@ -105,4 +92,4 @@
return this._menu;
}
-});
\ No newline at end of file
+});
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 794d517..0c84c48 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -485,20 +485,6 @@
/**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (var prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
-
- /**
* Filter the list and make it visible.
* This is always called once the prefix changes.
*
diff --git a/dev/js/src/menu/item.js b/dev/js/src/menu/item.js
index e369918..ea46287 100644
--- a/dev/js/src/menu/item.js
+++ b/dev/js/src/menu/item.js
@@ -25,20 +25,6 @@
/**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object] An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
-
- /**
* Get or set the content of the meun item.
*/
content : function (content) {
diff --git a/dev/js/src/menu/lengthField.js b/dev/js/src/menu/lengthField.js
index eed90b7..b7891c4 100644
--- a/dev/js/src/menu/lengthField.js
+++ b/dev/js/src/menu/lengthField.js
@@ -19,20 +19,6 @@
/**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
-
- /**
* Get the associated dom element.
*/
element : function () {
diff --git a/dev/js/src/menu/prefix.js b/dev/js/src/menu/prefix.js
index 20e2753..59a0ab5 100644
--- a/dev/js/src/menu/prefix.js
+++ b/dev/js/src/menu/prefix.js
@@ -36,20 +36,6 @@
/**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object} An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
-
- /**
* Get or set the activity status of the prefix.
*/
active : function (bool) {
diff --git a/dev/js/src/panel.js b/dev/js/src/panel.js
index 53ea757..63eea6c 100644
--- a/dev/js/src/panel.js
+++ b/dev/js/src/panel.js
@@ -124,20 +124,6 @@
if (e === view)
a[i] = undefined;
});
- },
-
-
- /**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object] An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
}
}
});
diff --git a/dev/js/src/util.js b/dev/js/src/util.js
index 42edf44..e227c67 100644
--- a/dev/js/src/util.js
+++ b/dev/js/src/util.js
@@ -27,6 +27,20 @@
return this.toLowerCase().replace(_slug1RE, '').replace(_slug2RE, '-');
};
+/**
+ * Upgrade this object to another object,
+ * while private data stays intact.
+ *
+ * @param {Object} An object with properties.
+ */
+Object.prototype.upgradeTo = function (props) {
+ for (let prop in props) {
+ this[prop] = props[prop];
+ };
+ return this;
+};
+
+
// Add toggleClass method similar to jquery
HTMLElement.prototype.toggleClass = function (c1, c2) {
const cl = this.classList;
@@ -201,4 +215,4 @@
//filter by actually being direct child node
classElements = classElements.filter(subElement => subElement.parentNode === element);
return classElements;
-};
\ No newline at end of file
+};
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index 06be1e0..4d6b8e4 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -14,18 +14,6 @@
},
- /**
- * Upgrade this object to another object
- * while private data stays intact
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
- },
-
-
ldType : function (type) {
if (arguments.length === 1)
this._ldType = type;
diff --git a/dev/js/src/view.js b/dev/js/src/view.js
index b45c485..326e603 100644
--- a/dev/js/src/view.js
+++ b/dev/js/src/view.js
@@ -119,20 +119,6 @@
};
this.panel.delView(this);
this._shown = false;
- },
-
-
- /**
- * Upgrade this object to another object,
- * while private data stays intact.
- *
- * @param {Object] An object with properties.
- */
- upgradeTo : function (props) {
- for (let prop in props) {
- this[prop] = props[prop];
- };
- return this;
}
};
});