Skip to content

Commit

Permalink
chore: Stop using "Object" in goog.Uri annotations (#7953)
Browse files Browse the repository at this point in the history
Related to #1672
  • Loading branch information
avelad committed Jan 29, 2025
1 parent f187cf7 commit 8674e72
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions third_party/closure-uri/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ goog.Uri.QueryData = function(query, uri) {
*/
goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() {
if (!this.keyMap_) {
this.keyMap_ = {};
this.keyMap_ = new Map();
this.count_ = 0;

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

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

if (!this.keyMap_.hasOwnProperty(key)) {
if (!this.keyMap_.has(key)) {
this.add(key, value);
} else {
this.keyMap_[key] = [value];
this.keyMap_.set(key, [value]);
}

return this;
Expand All @@ -838,7 +838,7 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
*/
goog.Uri.QueryData.prototype.get = function(key) {
this.ensureKeyMapInitialized_();
return this.keyMap_[key] || [];
return this.keyMap_.get(key) || [];
};


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

if (!this.keyMap_) {
if (!this.keyMap_ || !this.keyMap_.size) {
return '';
}

var sb = [];

for (var key in this.keyMap_) {
for (const key of this.keyMap_.keys()) {
var encodedKey = encodeURIComponent(key);
var val = this.keyMap_[key];
var val = this.keyMap_.get(key);
for (var j = 0; j < val.length; j++) {
var param = encodedKey;
// Ensure that null and undefined are encoded into the url as
Expand Down Expand Up @@ -891,9 +891,9 @@ goog.Uri.QueryData.prototype.clone = function() {
var rv = new goog.Uri.QueryData();
rv.encodedQuery_ = this.encodedQuery_;
if (this.keyMap_) {
var cloneMap = {};
for (var key in this.keyMap_) {
cloneMap[key] = this.keyMap_[key].concat();
var cloneMap = new Map();
for (const [key, val] of this.keyMap_) {
cloneMap.set(key, val.concat());
}
rv.keyMap_ = cloneMap;
rv.count_ = this.count_;
Expand Down

0 comments on commit 8674e72

Please sign in to comment.