File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -371,9 +371,14 @@ const extractTableDfns = table => {
371371 let res = [ ] ;
372372 const properties = [ ...table . querySelectorAll ( 'tr' ) ]
373373 . map ( line => {
374- const propName = dfnLabel2Property ( line . querySelector ( ':first-child' ) . textContent ) ;
374+ const nameEl = line . querySelector ( ':first-child' ) ;
375+ const valueEl = line . querySelector ( 'td:last-child' ) ;
376+ if ( ! nameEl || ! valueEl ) {
377+ return null ;
378+ }
379+ const propName = dfnLabel2Property ( nameEl . textContent ) ;
375380 if ( propName === 'name' ) {
376- const dfns = [ ...line . querySelectorAll ( 'td:last-child dfn[id]' ) ] ;
381+ const dfns = [ ...valueEl . querySelectorAll ( 'dfn[id]' ) ] ;
377382 if ( dfns . length > 0 ) {
378383 res = dfns . map ( dfn => Object . assign ( {
379384 name : normalize ( dfn . textContent ) ,
@@ -383,19 +388,22 @@ const extractTableDfns = table => {
383388 else {
384389 // Some tables may not have proper dfns, we won't be able to extract
385390 // IDs, but we can still extract the text
386- const value = normalize ( line . querySelector ( 'td:last-child' ) . textContent ) ;
391+ const value = normalize ( valueEl . textContent ) ;
387392 res = value . split ( ',' ) . map ( name => Object . assign ( {
388393 name : name . trim ( )
389394 } ) ) ;
390395 }
391396 return null ;
392397 }
393- else {
398+ else if ( propName ) {
394399 return {
395400 name : propName ,
396- value : normalize ( line . querySelector ( 'td:last-child' ) . textContent )
401+ value : normalize ( valueEl . textContent )
397402 } ;
398403 }
404+ else {
405+ return null ;
406+ }
399407 } )
400408 . filter ( property => ! ! property ) ;
401409
You can’t perform that action at this time.
0 commit comments