Skip to content
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

Merged
merged 2 commits into from
Jan 7, 2015

Conversation

tjlytle
Copy link
Contributor

@tjlytle tjlytle commented Jan 7, 2015

Logic was too broad, any value that could be considered false (like '0') would be treated as an empty tag.

philsturgeon added a commit that referenced this pull request Jan 7, 2015
Bugfix for HTML Element __toString()
@philsturgeon philsturgeon merged commit 8cc6e6a into thephpleague:master Jan 7, 2015
@@ -122,7 +122,7 @@ public function __toString()
$result .= ' ' . $key . '="' . $value . '"';
}

if ($this->contents) {
if (!is_null($this->contents) and $this->contents != '') {
Copy link
Member

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.

Copy link
Member

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 !== ''

Copy link
Member

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.

Copy link
Member

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>'

Copy link
Member

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.

Copy link
Member

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

@tjlytle
Copy link
Contributor Author

tjlytle commented Jan 7, 2015

Yeah, just looked at property declaration and the constructor, didn't think far enough that it shouldn't ever be null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants