File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1241,13 +1241,9 @@ class Catalog {
12411241 let javaScript = null ;
12421242
12431243 function appendIfJavaScriptDict ( name , jsDict ) {
1244- if ( ! ( jsDict instanceof Dict ) ) {
1244+ if ( ! ( jsDict instanceof Dict ) || ! isName ( jsDict . get ( "S" ) , "JavaScript" ) ) {
12451245 return ;
12461246 }
1247- if ( ! isName ( jsDict . get ( "S" ) , "JavaScript" ) ) {
1248- return ;
1249- }
1250-
12511247 let js = jsDict . get ( "JS" ) ;
12521248 if ( js instanceof BaseStream ) {
12531249 js = js . getString ( ) ;
@@ -1260,7 +1256,7 @@ class Catalog {
12601256 ) ;
12611257 // Skip empty entries, similar to the `_collectJS` function.
12621258 if ( js ) {
1263- ( javaScript || = new Map ( ) ) . set ( name , js ) ;
1259+ ( javaScript ?? = new Map ( ) ) . set ( name , js ) ;
12641260 }
12651261 }
12661262
@@ -1291,14 +1287,10 @@ class Catalog {
12911287 ) ;
12921288
12931289 if ( javaScript ) {
1294- actions || = Object . create ( null ) ;
1290+ actions ?? = Object . create ( null ) ;
12951291
12961292 for ( const [ key , val ] of javaScript ) {
1297- if ( key in actions ) {
1298- actions [ key ] . push ( val ) ;
1299- } else {
1300- actions [ key ] = [ val ] ;
1301- }
1293+ ( actions [ key ] ??= [ ] ) . push ( val ) ;
13021294 }
13031295 }
13041296 return shadow ( this , "jsActions" , actions ) ;
Original file line number Diff line number Diff line change @@ -803,27 +803,24 @@ class AnnotationElement {
803803 const fields = [ ] ;
804804
805805 if ( this . _fieldObjects ) {
806- const fieldObj = this . _fieldObjects [ name ] ;
807- if ( fieldObj ) {
808- for ( const { page, id, exportValues } of fieldObj ) {
809- if ( page === - 1 ) {
810- continue ;
811- }
812- if ( id === skipId ) {
813- continue ;
814- }
815- const exportValue =
816- typeof exportValues === "string" ? exportValues : null ;
817-
818- const domElement = document . querySelector (
819- `[data-element-id="${ id } "]`
820- ) ;
821- if ( domElement && ! GetElementsByNameSet . has ( domElement ) ) {
822- warn ( `_getElementsByName - element not allowed: ${ id } ` ) ;
823- continue ;
824- }
825- fields . push ( { id, exportValue, domElement } ) ;
806+ const fieldObj = this . _fieldObjects [ name ] || [ ] ;
807+
808+ for ( const { page, id, exportValues } of fieldObj ) {
809+ if ( page === - 1 ) {
810+ continue ;
811+ }
812+ if ( id === skipId ) {
813+ continue ;
814+ }
815+ const exportValue =
816+ typeof exportValues === "string" ? exportValues : null ;
817+
818+ const domElement = document . querySelector ( `[data-element-id="${ id } "]` ) ;
819+ if ( domElement && ! GetElementsByNameSet . has ( domElement ) ) {
820+ warn ( `_getElementsByName - element not allowed: ${ id } ` ) ;
821+ continue ;
826822 }
823+ fields . push ( { id, exportValue, domElement } ) ;
827824 }
828825 return fields ;
829826 }
You can’t perform that action at this time.
0 commit comments