File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
class AnnotationStorage {
20
20
constructor ( ) {
21
- this . _storage = Object . create ( null ) ;
21
+ this . _storage = new Map ( ) ;
22
22
}
23
23
24
24
/**
@@ -32,11 +32,11 @@ class AnnotationStorage {
32
32
* @returns {Object }
33
33
*/
34
34
getOrCreateValue ( key , defaultValue ) {
35
- if ( key in this . _storage ) {
36
- return this . _storage [ key ] ;
35
+ if ( this . _storage . has ( key ) ) {
36
+ return this . _storage . get ( key ) ;
37
37
}
38
38
39
- this . _storage [ key ] = defaultValue ;
39
+ this . _storage . set ( key , defaultValue ) ;
40
40
return defaultValue ;
41
41
}
42
42
@@ -49,11 +49,18 @@ class AnnotationStorage {
49
49
* @param {Object } value
50
50
*/
51
51
setValue ( key , value ) {
52
- this . _storage [ key ] = value ;
52
+ this . _storage . set ( key , value ) ;
53
53
}
54
54
55
55
getAll ( ) {
56
- return this . _storage ;
56
+ if ( this . _storage . size === 0 ) {
57
+ return null ;
58
+ }
59
+ return Object . fromEntries ( this . _storage ) ;
60
+ }
61
+
62
+ get size ( ) {
63
+ return this . _storage . size ;
57
64
}
58
65
}
59
66
Original file line number Diff line number Diff line change @@ -632,14 +632,13 @@ class PDFDocumentProxy {
632
632
constructor ( pdfInfo , transport ) {
633
633
this . _pdfInfo = pdfInfo ;
634
634
this . _transport = transport ;
635
- this . _annotationStorage = new AnnotationStorage ( ) ;
636
635
}
637
636
638
637
/**
639
638
* @type {AnnotationStorage } Storage for annotation data in forms.
640
639
*/
641
640
get annotationStorage ( ) {
642
- return this . _annotationStorage ;
641
+ return shadow ( this , "annotationStorage" , new AnnotationStorage ( ) ) ;
643
642
}
644
643
645
644
/**
You can’t perform that action at this time.
0 commit comments