File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 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) {
409409 if (in_array (strtolower ($ el ->tagName ), $ excludeTags )) {
410410 return $ out ;
411411 } else if ($ el ->tagName == 'img ' ) {
412- if ($ el ->getAttribute ('alt ' ) !== '' ) {
412+ if ($ el ->hasAttribute ('alt ' )) {
413413 return $ el ->getAttribute ('alt ' );
414- } else if (!$ implied && $ el ->getAttribute ('src ' ) !== '' ) {
414+ } else if (!$ implied && $ el ->hasAttribute ('src ' )) {
415415 return $ this ->resolveUrl ($ el ->getAttribute ('src ' ));
416416 }
417- } else if ($ el ->tagName == 'area ' and $ el ->getAttribute ('alt ' ) !== '' ) {
417+ } else if ($ el ->tagName == 'area ' and $ el ->hasAttribute ('alt ' )) {
418418 return $ el ->getAttribute ('alt ' );
419- } else if ($ el ->tagName == 'abbr ' and $ el ->getAttribute ('title ' ) !== '' ) {
419+ } else if ($ el ->tagName == 'abbr ' and $ el ->hasAttribute ('title ' )) {
420420 return $ el ->getAttribute ('title ' );
421421 }
422422 }
Original file line number Diff line number Diff line change @@ -115,4 +115,15 @@ public function testBrWhitespaceIssue69() {
115115 $ this ->assertEquals ('Street Name 9 ' . "\n" . '12345 NY, USA ' , $ result ['items ' ][0 ]['properties ' ]['name ' ][0 ]);
116116 }
117117
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+
118129}
You can’t perform that action at this time.
0 commit comments