1# ArkTS Subsystem Changelog 2 3## cl.arkts.1 Behavior of TreeSet.clear() and TreeMap.clear() Is Changed 4 5**Access Level** 6 7Public API 8 9**Reason for Change** 10 11The constructors of the **TreeMap** and **TreeSet** classes support the input of a comparator, through which you can control the position to which an element is inserted in the binary tree. 12 13When the **clear** API of **TreeMap** and **TreeSet** is called, the expected result is that only data is cleared. However, the actual result is that both the data and the passed-in comparator are cleared. As a result, when the API for inserting data is called again, the rules of the default comparator, rather than those of the passed-in comparator, are used. Consequently, the result does not meet the expectation. 14 15**Change Impact** 16 17This change is a non-compatible change. It affects the sorting rule after **clear()** is called. 18 19**Before Change** 20 21- Case 1: When a user passes in a comparator and calls the **clear** API of **TreeMap**, the comparator becomes invalid. 22 23 ``` 24 // Use comparator firstValue > secondValue to sort data in descending order. 25 let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 26 treeMap.set("aa","3"); 27 treeMap.set("dd","1"); 28 treeMap.set("cc","2"); 29 treeMap.set("bb","4"); 30 let numbers = Array.from(treeMap.keys()) 31 for (let item of numbers) { 32 console.log("treeMap:" + item); // key: dd cc bb aa 33 } 34 treeMap.clear(); 35 treeMap.set("aa","3"); 36 treeMap.set("dd","1"); 37 treeMap.set("cc","2"); 38 treeMap.set("bb","4"); 39 numbers = Array.from(treeMap.keys()) 40 for (let item of numbers) { 41 console.log("treeMap:" + item); //key: aa bb cc dd 42 } 43 ``` 44 45- Case 2: When a user passes in a comparator and calls the **clear** API of **TreeSet**, the comparator becomes invalid. 46 47 ``` 48 let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 49 treeSet.add("a"); 50 treeSet.add("c"); 51 treeSet.add("d"); 52 treeSet.add("b"); 53 let numbers = Array.from(treeSet.values()) 54 for (let item of numbers) { 55 console.log("TreeSet:" + item); // value: d c b a 56 } 57 treeSet.clear(); 58 treeSet.add("a"); 59 treeSet.add("c"); 60 treeSet.add("d"); 61 treeSet.add("b"); 62 numbers = Array.from(treeSet.values()) 63 for (let item of numbers) { 64 console.log("TreeSet:" + item); // value: a b c d 65 } 66 ``` 67 68**After Change** 69 70- Case 1: When a user passes in a comparator and calls the **clear** API of **TreeMap**, the comparator functions normally. 71 72 ``` 73 // Use comparator firstValue > secondValue to sort data in descending order. 74 let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 75 treeMap.set("aa","3"); 76 treeMap.set("dd","1"); 77 treeMap.set("cc","2"); 78 treeMap.set("bb","4"); 79 let numbers = Array.from(treeMap.keys()) 80 for (let item of numbers) { 81 console.log("treeMap:" + item); // treeMap: dd cc bb aa 82 } 83 treeMap.clear(); 84 treeMap.set("aa","3"); 85 treeMap.set("dd","1"); 86 treeMap.set("cc","2"); 87 treeMap.set("bb","4"); 88 numbers = Array.from(treeMap.keys()) 89 for (let item of numbers) { 90 console.log("treeMap:" + item); // treeMap: dd cc bb aa 91 } 92 ``` 93 94- Case 2: When a user passes in a comparator and calls the **clear** API of **TreeSet**, the comparator functions normally. 95 96 ``` 97 let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 98 treeSet.add("a"); 99 treeSet.add("c"); 100 treeSet.add("d"); 101 treeSet.add("b"); 102 let numbers = Array.from(treeSet.values()) 103 for (let item of numbers) { 104 console.log("TreeSet:" + item); // TreeSet: d c b a 105 } 106 treeSet.clear(); 107 treeSet.add("a"); 108 treeSet.add("c"); 109 treeSet.add("d"); 110 treeSet.add("b"); 111 numbers = Array.from(treeSet.values()) 112 for (let item of numbers) { 113 console.log("TreeSet:" + item); // TreeSet: d c b a 114 } 115 ``` 116 117**Start API Level** 118 1198 120 121**Change Since** 122 123OpenHarmony SDK 5.0.0.32 124 125**Key API/Component Changes** 126 127TreeMap.clear(); 128 129TreeSet.clear(); 130 131**Adaptation Guide** 132 133After the behavior of **TreeSet.clear()** and **TreeMap.clear()** is changed, you can sort elements without resetting the comparator. You can also reset the comparator to change the sorting mode of elements. 134 135The reference documents are as follows: 136 137[TreeMap.clear()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#clear) 138 139[TreeSet.clear()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#clear) 140 141## cl.arkts.2 Behavior of TreeMap.setAll() Is Changed 142 143**Access Level** 144 145Public API 146 147**Reason for Change** 148 149When **setAll** is called to add an empty tree map, the expected length is +0, but the actual length is +1. 150 151**Change Impact** 152 153This change is a non-compatible change. It affects the tree map length after **TreeMap.setAll()** is called. 154 155- Before change: When treeMap1 is added using **setAll**, the tree map length is 1. 156 157 ``` 158 let treeMap : TreeMap<string, number> = new TreeMap(); 159 let treeMap1 : TreeMap<string, number> = new TreeMap(); 160 treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap. 161 console.info("length:", treeMap.length) // length:1 162 ``` 163 164- After change: When treeMap1 is added using **setAll**, the tree map length is 0. 165 166 ``` 167 let treeMap : TreeMap<string, number> = new TreeMap(); 168 let treeMap1 : TreeMap<string, number> = new TreeMap(); 169 treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap. 170 console.info("length:",treeMap.length) // length:0 171 ``` 172 173**Start API Level** 174 1758 176 177**Change Since** 178 179OpenHarmony SDK 5.0.0.32 180 181**Key API/Component Changes** 182 183TreeMap.setAll(); 184 185**Adaptation Guide** 186 187If **TreeMap.setAll()** passes in an empty tree map, adapt to the tree map length changes. 188 189The reference documents are as follows: 190 191[TreeMap.setAll()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#setall) 192 193## cl.arkts.3 Behavior of hasKey and has of TreeMap and TreeSet Is Changed 194 195**Access Level** 196 197Public API 198 199**Reason for Change** 200 2011. For a **TreeMap** object with a user-defined comparator, the comparison relationship between undefined or null and other elements cannot be correctly distinguished. As a result, **hasKey(null/undefined)** returns **true** when null or undefined is not inserted. 2022. For a **TreeSet** object with a user-defined comparator, the comparison relationship between undefined or null and other elements cannot be correctly distinguished. As a result, **has(null/undefined)** returns **true** when null or undefined is not inserted. 203 204**Change Impact** 205 206This change is a non-compatible change. It affects the return value of **TreeMap.hasKey()** and **TreeSet.has()** when undefined or null is passed in. 207 208**Before Change** 209 210- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **true**. 211 212 ``` 213 let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 214 treeMap.set("aa",3); 215 treeMap.set("dd",1); 216 let res = treeMap.hasKey(null); 217 let res1 = treeMap.hasKey(undefined); 218 console.info("res:", res) // res:true 219 console.info("res1:",res1) // res1:true 220 ``` 221 222- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **true**. 223 224 ``` 225 let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 226 treeSet.add("a"); 227 treeSet.add("c"); 228 let res = treeSet.has(null); 229 let res1 = treeSet.has(undefined); 230 console.info("res:", res) // res:true 231 console.info("res1:",res1) // res1:true 232 ``` 233 234**After Change** 235 236- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **false**. 237 238 ``` 239 let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 240 treeMap.set("aa",3); 241 treeMap.set("dd",1); 242 let res = treeMap.hasKey(null); 243 let res1 = treeMap.hasKey(undefined); 244 console.info("res:", res) // res:false 245 console.info("res1:",res1) // res1:false 246 ``` 247 248- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **false**. 249 250 ``` 251 let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 252 treeSet.add("a"); 253 treeSet.add("c"); 254 let res = treeSet.has(null); 255 let res1 = treeSet.has(undefined); 256 console.info("res:", res) // res:false 257 console.info("res1:",res1) // res1:false 258 ``` 259 260 261**Start API Level** 262 2638 264 265**Change Since** 266 267OpenHarmony SDK 5.0.0.32 268 269**Key API/Component Changes** 270 271TreeMap.hasKey(); 272 273TreeSet.has(); 274 275**Adaptation Guide** 276 277When null or undefined is passed in, you need to adapt to the return value changes of **TreeMap.hasKey()** and **TreeSet.has()**. 278 279The reference documents are as follows: 280 281[TreeMap.hasKey()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#haskey) 282 283[TreeSet.has()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#has) 284 285 286## cl.arkts.4 Behavior Is Changed When the Value Added by append of the URLParams Class Contains Consecutive Spaces 287 288**Access Level** 289 290Public API 291 292**Reason for Change** 293 294If a string added by the **append** API of the **URLParams** class contains consecutive spaces, the consecutive spaces are incorrectly converted to only one plus sign (+). This implementation does not comply with the URL standard. 295 296 **Change Impact** 297 298This change is a non-compatible change. It affects the processing result of the **URLParams.append()** API when the input parameter contains consecutive spaces. 299 300**Start API Level** 301 3029 303 304**Change Since** 305 306OpenHarmony SDK 5.0.0.32 307 308**Key API/Component Changes** 309 310**append** of a **URLParams** object. 311 312Before change: When a **URLParams** object uses **append()** to add the key-value pair that contains consecutive spaces, the API converts the consecutive spaces to only one plus sign (+). 313```ts 314{ 315 const objectParams = new url.URLParams("key=abc") 316 console.log(objectParams.toString()) // "key=abc" 317 objectParams.append('key1', 'd e f'); 318 console.log(objectParams.toString()) // "key=abc&key1=d+e+f" 319} 320``` 321 322After change: When a **URLParams** object uses **append()** to add the key-value pair that contains multiple consecutive spaces, the API converts the consecutive spaces to the corresponding number of plus signs (+). 323```ts 324{ 325 const objectParams = new url.URLParams("key=abc") 326 console.log(objectParams.toString()) // "key=abc" 327 objectParams.append('key1', 'd e f'); 328 console.log(objectParams.toString()) // "key=abc&key1=d+++e+++f" 329} 330``` 331 332**Adaptation Guide** 333 334If the preceding scenario is used in your code, make adaptation to the key-value pairs added by **append** accordingly. 335 336## cl.arkts.5 Return Value of toString() of the URLParams Class Is Inconsistent When the Passed-in String Contains Both Uppercase and Lowercase Encoding Values 337 338**Access Level** 339 340Public API 341 342**Reason for Change** 343 344For the **URLParams** class, the return value of the **toString()** API is incorrect when the passed-in string contains of the URLParams constructor both uppercase and lowercase encoding values. Specifically, "%2B" is processed as "%2B", whereas "%2b" is incorrectly processed as "+". 345 346 **Change Impact** 347 348This change is a non-compatible change. It affects the return value of **URLParams.toString()** when the passed-in string of the URLParams constructor contains "%2b". 349 350**Start API Level** 351 3529 353 354**Change Since** 355 356OpenHarmony SDK 5.0.0.32 357 358**Key API/Component Changes** 359 360**toString** API of the URLParams class of the URL module. 361 362Before change: During the creation of a URLParams object, if both "%2b" and "%2B" exist in the passed-in string, they are displayed as "+" and "%2B" in the return value of **toString()**, respectively. 363```ts 364{ 365 const objectParams = new url.URLParams("key%2b=abc%2B") 366 console.log(objectParams.toString()) // "key+=abc%2B" 367} 368``` 369 370After change: During the creation of a URLParams object, if both "%2b" and "%2B" exist in the passed-in string, they are displayed both as "%2B" in the return value of **toString()**. 371```ts 372{ 373 const objectParams = new url.URLParams("key%2b=abc%2B") 374 console.log(objectParams.toString()) // "key%2B=abc%2B" 375} 376``` 377 378**Adaptation Guide** 379 380If the preceding scenario is used in your code, make adaptation to the return value of **toString()**. 381 382## cl.arkts.6 Behavior of append of the URLParams Class Is Changed 383 384**Access Level** 385 386Public API 387 388**Reason for Change** 389 390When the **append()** API of the **URLParams** class is called, special characters in the passed-in key-value pair are incorrectly encoded. This behavior is inconsistent with the URL standard. As a result, exceptions occur when the key-value pair is added, deleted, modified, or queried. 391 392 **Change Impact** 393 394This change is a non-compatible change. If affects the processing result of the **URLParams.append()** API when the passed-in key-value pair contains special characters such as Chinese characters. 395 396**Start API Level** 397 3989 399 400**Change Since** 401 402OpenHarmony SDK 5.0.0.32 403 404**Key API/Component Changes** 405 406**append** API of the **URLParams** class. 407 408Before change: The **append()** API of the **URLParams** class is used to add a key-value pair. When you want to use the **get**, **has**, **delete**, or **set** API with the added key to add, delete, modify, or query data, you must encode the key first. 409```ts 410{ 411 const objectParams = new url.URLParams('?fod=1&bard=2') 412 objectParams.append("key&大", "abc"); 413 objectParams.has('key&大'); // false 414 objectParams.has('%E5%A4%A7'); // true 415 objectParams.get('key&大'); // undefined 416 objectParams.get('%E5%A4%A7'); // abc 417} 418``` 419 420After change: The **append()** API of the **URLParams** class is used to add a key-value pair. You can directly use the added key to obtain the corresponding value for adding, deleting, modifying, and querying. 421```ts 422{ 423 const objectParams = new url.URLParams('?fod=1&bard=2') 424 objectParams.append("key&大", "abc"); 425 objectParams.has('key&大'); // true 426 objectParams.has('%E5%A4%A7'); // false 427 objectParams.get('key&大'); // abc 428 objectParams.get('%E5%A4%A7'); // undefined 429} 430``` 431 432**Adaptation Guide** 433 434If the passed-in parameter of **URLParams.append()** contains special characters such as Chinese characters, you need to adapt to the changes in the processing result and return value of **has()**, **get()**, **delete()**, and **set()**. 435 436 <!--no_check-->