• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
25let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
26treeMap.set("aa","3");
27treeMap.set("dd","1");
28treeMap.set("cc","2");
29treeMap.set("bb","4");
30let numbers = Array.from(treeMap.keys())
31for (let item of numbers) {
32  console.log("treeMap:" + item); // key: dd  cc  bb  aa
33}
34treeMap.clear();
35treeMap.set("aa","3");
36treeMap.set("dd","1");
37treeMap.set("cc","2");
38treeMap.set("bb","4");
39numbers = Array.from(treeMap.keys())
40for (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```
48let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
49treeSet.add("a");
50treeSet.add("c");
51treeSet.add("d");
52treeSet.add("b");
53let numbers = Array.from(treeSet.values())
54for (let item of numbers) {
55  console.log("TreeSet:" + item); // value: d  c  b  a
56}
57treeSet.clear();
58treeSet.add("a");
59treeSet.add("c");
60treeSet.add("d");
61treeSet.add("b");
62numbers = Array.from(treeSet.values())
63for (let item of numbers) {
64  console.log("TreeSet:" + item); // value: a  b  c  d
65}
66```
67**After Change**
68
69- Case 1: When a user passes in a comparator and calls the **clear** API of **TreeMap**, the comparator functions normally.
70
71```
72// Use comparator firstValue > secondValue to sort data in descending order.
73let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
74treeMap.set("aa","3");
75treeMap.set("dd","1");
76treeMap.set("cc","2");
77treeMap.set("bb","4");
78let numbers = Array.from(treeMap.keys())
79for (let item of numbers) {
80  console.log("treeMap:" + item); // treeMap: dd  cc  bb  aa
81}
82treeMap.clear();
83treeMap.set("aa","3");
84treeMap.set("dd","1");
85treeMap.set("cc","2");
86treeMap.set("bb","4");
87numbers = Array.from(treeMap.keys())
88for (let item of numbers) {
89  console.log("treeMap:" + item); // treeMap: dd  cc  bb  aa
90}
91```
92
93- Case 2: When a user passes in a comparator and calls the **clear** API of **TreeSet**, the comparator functions normally.
94
95```
96let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
97treeSet.add("a");
98treeSet.add("c");
99treeSet.add("d");
100treeSet.add("b");
101let numbers = Array.from(treeSet.values())
102for (let item of numbers) {
103  console.log("TreeSet:" + item); // TreeSet: d  c  b  a
104}
105treeSet.clear();
106treeSet.add("a");
107treeSet.add("c");
108treeSet.add("d");
109treeSet.add("b");
110numbers = Array.from(treeSet.values())
111for (let item of numbers) {
112  console.log("TreeSet:" + item); // TreeSet: d  c  b  a
113}
114```
115**Start API Level**
116
1178
118
119**Change Since**
120
121OpenHarmony SDK 5.0.0.32
122
123**Key API/Component Changes**
124
125TreeMap.clear();
126
127TreeSet.clear();
128
129**Adaptation Guide**
130
131After 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.
132
133The reference documents are as follows:
134
135[TreeMap.clear()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#clear)
136
137[TreeSet.clear()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#clear)
138
139## cl.arkts.2 Behavior of TreeMap.setAll() Is Changed
140
141**Access Level**
142
143Public API
144
145**Reason for Change**
146
147When **setAll** is called to add an empty tree map, the expected length is +0, but the actual length is +1.
148
149**Change Impact**
150
151This change is a non-compatible change. It affects the tree map length after **TreeMap.setAll()** is called.
152
153- Before change: When treeMap1 is added using **setAll**, the tree map length is 1.
154
155```
156let treeMap : TreeMap<string, number> = new TreeMap();
157let treeMap1 : TreeMap<string, number> = new TreeMap();
158treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap.
159console.info("length:", treeMap.length) // length:1
160```
161
162- After change: When treeMap1 is added using **setAll**, the tree map length is 0.
163
164```
165let treeMap : TreeMap<string, number> = new TreeMap();
166let treeMap1 : TreeMap<string, number> = new TreeMap();
167treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap.
168console.info("length:",treeMap.length) // length:0
169```
170
171**Start API Level**
172
1738
174
175**Change Since**
176
177OpenHarmony SDK 5.0.0.32
178
179**Key API/Component Changes**
180
181TreeMap.setAll();
182
183**Adaptation Guide**
184
185If **TreeMap.setAll()** passes in an empty tree map, adapt to the tree map length changes.
186
187The reference documents are as follows:
188
189[TreeMap.setAll()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#setall)
190
191## cl.arkts.3 Behavior of hasKey and has of TreeMap and TreeSet Is Changed
192
193**Access Level**
194
195Public API
196
197**Reason for Change**
198
1991. 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.
2002. 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.
201
202**Change Impact**
203
204This change is a non-compatible change. It affects the return value of **TreeMap.hasKey()** and **TreeSet.has()** when undefined or null is passed in.
205
206- **Before Change**
207
208- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **true**.
209
210```
211let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
212treeMap.set("aa",3);
213treeMap.set("dd",1);
214let res = treeMap.hasKey(null);
215let res1 = treeMap.hasKey(undefined);
216console.info("res:", res) // res:true
217console.info("res1:",res1) // res1:true
218```
219
220- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **true**.
221
222```
223let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
224treeSet.add("a");
225treeSet.add("c");
226let res = treeSet.has(null);
227let res1 = treeSet.has(undefined);
228console.info("res:", res) // res:true
229console.info("res1:",res1) // res1:true
230```
231
232- **After Change**
233
234- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **false**.
235
236```
237let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
238treeMap.set("aa",3);
239treeMap.set("dd",1);
240let res = treeMap.hasKey(null);
241let res1 = treeMap.hasKey(undefined);
242console.info("res:", res) // res:false
243console.info("res1:",res1) // res1:false
244```
245
246- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **false**.
247
248```
249let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue});
250treeSet.add("a");
251treeSet.add("c");
252let res = treeSet.has(null);
253let res1 = treeSet.has(undefined);
254console.info("res:", res) // res:false
255console.info("res1:",res1) // res1:false
256```
257
258
259**Start API Level**
260
2618
262
263**Change Since**
264
265OpenHarmony SDK 5.0.0.32
266
267**Key API/Component Changes**
268
269TreeMap.hasKey();
270TreeSet.has();
271
272**Adaptation Guide**
273
274When null or undefined is passed in, you need to adapt to the return value changes of **TreeMap.hasKey()** and **TreeSet.has()**.
275
276The reference documents are as follows:
277
278[TreeMap.hasKey()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#haskey)
279
280[TreeSet.has()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#has)
281
282
283## cl.arkts.4 Behavior Is Changed When the Value Added by append of the URLParams Class Contains Consecutive Spaces
284
285**Access Level**
286
287Public API
288
289**Reason for Change**
290
291If 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.
292
293 **Change Impact**
294
295This change is a non-compatible change. It affects the processing result of the **URLParams.append()** API when the input parameter contains consecutive spaces.
296
297**Start API Level**
298
2999
300
301**Change Since**
302
303OpenHarmony SDK 5.0.0.32
304
305**Key API/Component Changes**
306
307**append** of a **URLParams** object.
308
309Before 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 (+).
310```ts
311{
312    const objectParams = new url.URLParams("key=abc")
313    console.log(objectParams.toString())  // "key=abc"
314    objectParams.append('key1', 'd   e   f');
315    console.log(objectParams.toString())  // "key=abc&key1=d+e+f"
316}
317```
318
319After 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 (+).
320```ts
321{
322    const objectParams = new url.URLParams("key=abc")
323    console.log(objectParams.toString())  // "key=abc"
324    objectParams.append('key1', 'd   e   f');
325    console.log(objectParams.toString())  // "key=abc&key1=d+++e+++f"
326}
327```
328
329**Adaptation Guide**
330
331If the preceding scenario is used in your code, make adaptation to the key-value pairs added by **append** accordingly.
332
333## 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
334
335**Access Level**
336
337Public API
338
339**Reason for Change**
340
341For 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 "+".
342
343 **Change Impact**
344
345This 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".
346
347**Start API Level**
348
3499
350
351**Change Since**
352
353OpenHarmony SDK 5.0.0.32
354
355**Key API/Component Changes**
356
357**toString** API of the URLParams class of the URL module.
358
359Before 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.
360```ts
361{
362    const objectParams = new url.URLParams("key%2b=abc%2B")
363    console.log(objectParams.toString())  // "key+=abc%2B"
364}
365```
366
367After 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()**.
368```ts
369{
370    const objectParams = new url.URLParams("key%2b=abc%2B")
371    console.log(objectParams.toString())  // "key%2B=abc%2B"
372}
373```
374
375**Adaptation Guide**
376
377If the preceding scenario is used in your code, make adaptation to the return value of **toString()**.
378
379## cl.arkts.6 Behavior of append of the URLParams Class Is Changed
380
381**Access Level**
382
383Public API
384
385**Reason for Change**
386
387When 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.
388
389 **Change Impact**
390
391This 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.
392
393**Start API Level**
394
3959
396
397**Change Since**
398
399OpenHarmony SDK 5.0.0.32
400
401**Key API/Component Changes**
402
403**append** API of the **URLParams** class.
404
405Before 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.
406```ts
407{
408    const objectParams = new url.URLParams('?fod=1&bard=2')
409    objectParams.append("key&large", "abc");
410    objectParams.has('key&large');  // false
411    objectParams.has('%E5%A4%A7');  // true
412    objectParams.get('key&large'); // undefined
413    objectParams.get('%E5%A4%A7');  // abc
414}
415```
416
417After 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.
418```ts
419{
420    const objectParams = new url.URLParams('?fod=1&bard=2')
421    objectParams.append("key&large", "abc");
422    objectParams.has('key&large');  // true
423    objectParams.has('%E5%A4%A7');  // false
424    objectParams.get('key&large'); // abc
425    objectParams.get('%E5%A4%A7');  // undefined
426}
427```
428
429**Adaptation Guide**
430
431If 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()**.
432