Created
June 22, 2020 13:36
-
-
Save navarr/0bd8377996c65a1a7ad72b4d8962956a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 960e6242ce7c0090e72cc1d70a858a84198a5158 Mon Sep 17 00:00:00 2001 | |
From: Navarr Barnier <[email protected]> | |
Date: Tue, 2 Jun 2020 11:17:14 -0400 | |
Subject: [PATCH] BUNDLE-2583 | |
--- | |
.../web/js/view/validation-message.js | 32 +++++++++++++++---- | |
1 file changed, 26 insertions(+), 6 deletions(-) | |
diff --git a/vendor/vertex/module-address-validation/view/frontend/web/js/view/validation-message.js b/vendor/vertex/module-address-validation/view/frontend/web/js/view/validation-message.js | |
index 67006b23..2aa4f3c2 100644 | |
--- a/vendor/vertex/module-address-validation/view/frontend/web/js/view/validation-message.js | |
+++ b/vendor/vertex/module-address-validation/view/frontend/web/js/view/validation-message.js | |
@@ -23,7 +23,7 @@ define([ | |
*/ | |
initObservable: function () { | |
this.hasMessage = ko.pureComputed(function() { | |
- return Object.entries(this.message).length !== 0; | |
+ return this._objectHasEntries(this.message); | |
}.bind(this)); | |
return this._super(); | |
@@ -72,11 +72,9 @@ define([ | |
* @returns {Boolean} | |
*/ | |
hasMessage: function () { | |
- var message = this.message; | |
- | |
return ko.computed(function () { | |
- return Object.entries(message).length !== 0 | |
- }); | |
+ return this._objectHasEntries(this.message); | |
+ }.bind(this)); | |
}, | |
/** | |
@@ -86,6 +84,28 @@ define([ | |
*/ | |
clear: function () { | |
this.message = {}; | |
- } | |
+ }, | |
+ | |
+ /** | |
+ * Return whether or not the object has any entries | |
+ * | |
+ * Object.entries is not supported by IE11 or Opera Mini. | |
+ * Writing a quick method to serve the same purpose was easier than | |
+ * importing a shim. | |
+ * | |
+ * @param {Object} object | |
+ * @returns {boolean} | |
+ * @private | |
+ */ | |
+ _objectHasEntries: function(object) { | |
+ if (typeof Object.entries !== 'undefined') { | |
+ return Object.entries(object).length !== 0; | |
+ } | |
+ for (let key in object) { | |
+ if (object.hasOwnProperty(key)) { | |
+ return true; | |
+ } | |
+ } | |
+ }, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment