@@ -60,10 +60,10 @@ function extractAllLinks() {
6060 * @return {Array }
6161 */
6262function findLinks ( root ) {
63- console . debug ( 'findLinks:' , root )
63+ // console.debug('findLinks:', root)
6464 const links = [ ]
6565 if ( root . querySelectorAll ) {
66- root . querySelectorAll ( 'a' ) . forEach ( ( el ) => {
66+ root . querySelectorAll ( 'a, area ' ) . forEach ( ( el ) => {
6767 pushElement ( links , el )
6868 } )
6969 }
@@ -95,9 +95,10 @@ function extractSelection() {
9595 if ( ancestor . nodeName === '#text' ) {
9696 continue
9797 }
98- ancestor . querySelectorAll ( 'a' ) . forEach ( ( element ) => {
99- if ( selection . containsNode ( element , true ) ) {
100- pushElement ( links , element )
98+ ancestor . querySelectorAll ( 'a, area' ) . forEach ( ( el ) => {
99+ if ( selection . containsNode ( el , true ) ) {
100+ // console.debug('el:', el)
101+ pushElement ( links , el )
101102 }
102103 } )
103104 }
@@ -114,16 +115,18 @@ function extractSelection() {
114115function pushElement ( array , element ) {
115116 // console.debug('element:', element)
116117 try {
117- const data = {
118- href : decodeURI ( element . href ) ,
119- text : element . textContent ?. trim ( ) ,
120- title : element . title ,
121- label : element . ariaLabel || '' ,
122- rel : element . rel ,
123- target : element . target ,
124- origin : element . origin ,
118+ if ( element . href ) {
119+ const data = {
120+ href : decodeURI ( element . href ) ,
121+ text : element . textContent ?. trim ( ) ,
122+ title : element . title ,
123+ label : element . ariaLabel || '' ,
124+ rel : element . rel ,
125+ target : element . target ,
126+ origin : element . origin ,
127+ }
128+ array . push ( data )
125129 }
126- array . push ( data )
127130 } catch ( e ) {
128131 console . log ( e )
129132 }
0 commit comments