File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -409,14 +409,14 @@ public function innerText($el, $implied=false) {
409
409
if (in_array (strtolower ($ el ->tagName ), $ excludeTags )) {
410
410
return $ out ;
411
411
} else if ($ el ->tagName == 'img ' ) {
412
- if ($ el ->getAttribute ('alt ' ) !== '' ) {
412
+ if ($ el ->hasAttribute ('alt ' )) {
413
413
return $ el ->getAttribute ('alt ' );
414
- } else if (!$ implied && $ el ->getAttribute ('src ' ) !== '' ) {
414
+ } else if (!$ implied && $ el ->hasAttribute ('src ' )) {
415
415
return $ this ->resolveUrl ($ el ->getAttribute ('src ' ));
416
416
}
417
- } else if ($ el ->tagName == 'area ' and $ el ->getAttribute ('alt ' ) !== '' ) {
417
+ } else if ($ el ->tagName == 'area ' and $ el ->hasAttribute ('alt ' )) {
418
418
return $ el ->getAttribute ('alt ' );
419
- } else if ($ el ->tagName == 'abbr ' and $ el ->getAttribute ('title ' ) !== '' ) {
419
+ } else if ($ el ->tagName == 'abbr ' and $ el ->hasAttribute ('title ' )) {
420
420
return $ el ->getAttribute ('title ' );
421
421
}
422
422
}
Original file line number Diff line number Diff line change @@ -115,4 +115,15 @@ public function testBrWhitespaceIssue69() {
115
115
$ this ->assertEquals ('Street Name 9 ' . "\n" . '12345 NY, USA ' , $ result ['items ' ][0 ]['properties ' ]['name ' ][0 ]);
116
116
}
117
117
118
+ /**
119
+ * @see https://github.com/indieweb/php-mf2/issues/89
120
+ */
121
+ public function testEmptyAlt () {
122
+ $ input = '<div class="p-author h-card"><a href="/" class="p-org p-name"><img class="u-logo" src="/static/logo.jpg" alt="" />mention.tech</a></div> ' ;
123
+ $ result = Mf2 \parse ($ input );
124
+
125
+ $ this ->assertEquals ('mention.tech ' , $ result ['items ' ][0 ]['properties ' ]['org ' ][0 ]);
126
+ $ this ->assertEquals ('mention.tech ' , $ result ['items ' ][0 ]['properties ' ]['name ' ][0 ]);
127
+ }
128
+
118
129
}
You can’t perform that action at this time.
0 commit comments