@@ -733,7 +733,7 @@ goog.Uri.QueryData = function(query, uri) {
733
733
*/
734
734
goog . Uri . QueryData . prototype . ensureKeyMapInitialized_ = function ( ) {
735
735
if ( ! this . keyMap_ ) {
736
- this . keyMap_ = { } ;
736
+ this . keyMap_ = new Map ( ) ;
737
737
this . count_ = 0 ;
738
738
739
739
if ( this . encodedQuery_ ) {
@@ -764,7 +764,7 @@ goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() {
764
764
* We need to use a Map because we cannot guarantee that the key names will
765
765
* not be problematic for IE.
766
766
*
767
- * @type {Object <string, !Array<string>> }
767
+ * @type {Map <string, !Array<string>> }
768
768
* @private
769
769
*/
770
770
goog . Uri . QueryData . prototype . keyMap_ = null ;
@@ -798,9 +798,9 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
798
798
// Invalidate the cache.
799
799
this . encodedQuery_ = null ;
800
800
801
- var values = this . keyMap_ . hasOwnProperty ( key ) ? this . keyMap_ [ key ] : null ;
801
+ var values = this . keyMap_ . has ( key ) ? this . keyMap_ . get ( key ) : null ;
802
802
if ( ! values ) {
803
- this . keyMap_ [ key ] = ( values = [ ] ) ;
803
+ this . keyMap_ . set ( key , ( values = [ ] ) ) ;
804
804
}
805
805
values . push ( value ) ;
806
806
goog . asserts . assert ( this . count_ != null , 'Should not be null.' ) ;
@@ -820,10 +820,10 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
820
820
// Invalidate the cache.
821
821
this . encodedQuery_ = null ;
822
822
823
- if ( ! this . keyMap_ . hasOwnProperty ( key ) ) {
823
+ if ( ! this . keyMap_ . has ( key ) ) {
824
824
this . add ( key , value ) ;
825
825
} else {
826
- this . keyMap_ [ key ] = [ value ] ;
826
+ this . keyMap_ . set ( key , [ value ] ) ;
827
827
}
828
828
829
829
return this ;
@@ -838,7 +838,7 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
838
838
*/
839
839
goog . Uri . QueryData . prototype . get = function ( key ) {
840
840
this . ensureKeyMapInitialized_ ( ) ;
841
- return this . keyMap_ [ key ] || [ ] ;
841
+ return this . keyMap_ . get ( key ) || [ ] ;
842
842
} ;
843
843
844
844
@@ -851,15 +851,15 @@ goog.Uri.QueryData.prototype.toString = function() {
851
851
return this . encodedQuery_ ;
852
852
}
853
853
854
- if ( ! this . keyMap_ ) {
854
+ if ( ! this . keyMap_ || ! this . keyMap_ . size ) {
855
855
return '' ;
856
856
}
857
857
858
858
var sb = [ ] ;
859
859
860
- for ( var key in this . keyMap_ ) {
860
+ for ( const key of this . keyMap_ . keys ( ) ) {
861
861
var encodedKey = encodeURIComponent ( key ) ;
862
- var val = this . keyMap_ [ key ] ;
862
+ var val = this . keyMap_ . get ( key ) ;
863
863
for ( var j = 0 ; j < val . length ; j ++ ) {
864
864
var param = encodedKey ;
865
865
// Ensure that null and undefined are encoded into the url as
@@ -891,9 +891,9 @@ goog.Uri.QueryData.prototype.clone = function() {
891
891
var rv = new goog . Uri . QueryData ( ) ;
892
892
rv . encodedQuery_ = this . encodedQuery_ ;
893
893
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 ( ) ) ;
897
897
}
898
898
rv . keyMap_ = cloneMap ;
899
899
rv . count_ = this . count_ ;
0 commit comments