-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix for HTML Element __toString() #55
Bugfix for HTML Element __toString() #55
Conversation
Bugfix for HTML Element __toString()
@@ -122,7 +122,7 @@ public function __toString() | |||
$result .= ' ' . $key . '="' . $value . '"'; | |||
} | |||
|
|||
if ($this->contents) { | |||
if (!is_null($this->contents) and $this->contents != '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->contents
should never be null
, so we could remove that first check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also probably be !== ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we should use &&
over and
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Graham.
@colinodell with the suggested change made, tests are reporting the following:
1) League\CommonMark\Tests\HtmlElementTest::testToString
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p></p><img />'
+'<p></p><img></img>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh I'm probably using null
somewhere I shouldn't be. /facepalm
I'll look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that was my bad: 34884ce
Yeah, just looked at property declaration and the constructor, didn't think far enough that it shouldn't ever be |
Logic was too broad, any value that could be considered false (like '0') would be treated as an empty tag.