Skip to content

Commit 52fb15d

Browse files
authoredJan 27, 2025··
chore: Stop using "Object" in goog.Uri annotations (#7953)
Related to #1672
1 parent e3e4c15 commit 52fb15d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed
 

‎third_party/closure-uri/uri.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ goog.Uri.QueryData = function(query, uri) {
733733
*/
734734
goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() {
735735
if (!this.keyMap_) {
736-
this.keyMap_ = {};
736+
this.keyMap_ = new Map();
737737
this.count_ = 0;
738738

739739
if (this.encodedQuery_) {
@@ -764,7 +764,7 @@ goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() {
764764
* We need to use a Map because we cannot guarantee that the key names will
765765
* not be problematic for IE.
766766
*
767-
* @type {Object<string, !Array<string>>}
767+
* @type {Map<string, !Array<string>>}
768768
* @private
769769
*/
770770
goog.Uri.QueryData.prototype.keyMap_ = null;
@@ -798,9 +798,9 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
798798
// Invalidate the cache.
799799
this.encodedQuery_ = null;
800800

801-
var values = this.keyMap_.hasOwnProperty(key) ? this.keyMap_[key] : null;
801+
var values = this.keyMap_.has(key) ? this.keyMap_.get(key) : null;
802802
if (!values) {
803-
this.keyMap_[key] = (values = []);
803+
this.keyMap_.set(key, (values = []));
804804
}
805805
values.push(value);
806806
goog.asserts.assert(this.count_ != null, 'Should not be null.');
@@ -820,10 +820,10 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
820820
// Invalidate the cache.
821821
this.encodedQuery_ = null;
822822

823-
if (!this.keyMap_.hasOwnProperty(key)) {
823+
if (!this.keyMap_.has(key)) {
824824
this.add(key, value);
825825
} else {
826-
this.keyMap_[key] = [value];
826+
this.keyMap_.set(key, [value]);
827827
}
828828

829829
return this;
@@ -838,7 +838,7 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
838838
*/
839839
goog.Uri.QueryData.prototype.get = function(key) {
840840
this.ensureKeyMapInitialized_();
841-
return this.keyMap_[key] || [];
841+
return this.keyMap_.get(key) || [];
842842
};
843843

844844

@@ -851,15 +851,15 @@ goog.Uri.QueryData.prototype.toString = function() {
851851
return this.encodedQuery_;
852852
}
853853

854-
if (!this.keyMap_) {
854+
if (!this.keyMap_ || !this.keyMap_.size) {
855855
return '';
856856
}
857857

858858
var sb = [];
859859

860-
for (var key in this.keyMap_) {
860+
for (const key of this.keyMap_.keys()) {
861861
var encodedKey = encodeURIComponent(key);
862-
var val = this.keyMap_[key];
862+
var val = this.keyMap_.get(key);
863863
for (var j = 0; j < val.length; j++) {
864864
var param = encodedKey;
865865
// Ensure that null and undefined are encoded into the url as
@@ -891,9 +891,9 @@ goog.Uri.QueryData.prototype.clone = function() {
891891
var rv = new goog.Uri.QueryData();
892892
rv.encodedQuery_ = this.encodedQuery_;
893893
if (this.keyMap_) {
894-
var cloneMap = {};
895-
for (var key in this.keyMap_) {
896-
cloneMap[key] = this.keyMap_[key].concat();
894+
var cloneMap = new Map();
895+
for (const [key, val] of this.keyMap_) {
896+
cloneMap.set(key, val.concat());
897897
}
898898
rv.keyMap_ = cloneMap;
899899
rv.count_ = this.count_;

0 commit comments

Comments
 (0)
Please sign in to comment.