This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,18 @@ function collectElementByIDs(element) {
1010 }
1111
1212 const { parents } = element ;
13- if ( parents ) {
14- const rootElement = parents . get ( 0 ) ;
15-
16- if ( rootElement ) {
17- rootElement . recursiveChildren . forEach ( ( element ) => {
18- if ( element . id ) {
19- dataStructures [ element . id . toValue ( ) ] = element ;
20- }
21- } ) ;
22- }
13+ if ( ! parents || parents . isEmpty ) {
14+ return dataStructures ;
15+ }
16+
17+ const rootElement = parents . get ( parents . length - 1 ) ;
18+
19+ if ( rootElement ) {
20+ rootElement . recursiveChildren . forEach ( ( element ) => {
21+ if ( element . id ) {
22+ dataStructures [ element . id . toValue ( ) ] = element ;
23+ }
24+ } ) ;
2325 }
2426
2527 return dataStructures ;
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ describe('#serializeForm', () => {
2626 new namespace . elements . Category ( [
2727 new namespace . elements . String ( 'Hello world' , { id : 'message' } ) ,
2828 ] , { classes : [ 'dataStructures' ] } ) ,
29- element ,
29+ new namespace . elements . Category ( [
30+ element ,
31+ ] ) ,
3032 ] ) . freeze ( ) ;
3133
3234 expect ( serializeForm ( { api : element , mediaType : 'multipart/form-data' } ) ) . to . equal ( '--BOUNDARY\r\nContent-Disposition: form-data; name="undefined"\r\n\r\nHello world\r\n--BOUNDARY--\r\n' ) ;
You can’t perform that action at this time.
0 commit comments