Allows empty attributes in html tag helper#36
Merged
NoahDragon merged 1 commit intohexojs:masterfrom Aug 29, 2018
Merged
Conversation
675e9c3 to
b8a6b29
Compare
JLHwung
previously approved these changes
Aug 1, 2018
lib/html_tag.js
Outdated
|
|
||
| for (var i in attrs) { | ||
| if (attrs[i]) result += ' ' + i + '="' + attrs[i] + '"'; | ||
| if (attrs[i] || attrs[i] === '') result += ' ' + i + '="' + attrs[i] + '"'; |
Contributor
There was a problem hiding this comment.
I suggest we use stricter attrs[i] !== undefined && attrs[i] !== null on this check.
Author
There was a problem hiding this comment.
There is an error already if an attribute is not defined. Should I add the test?
it('tag + empty attr', function() {
try {
htmlTag('img', {
src: 'http://placekitten.com/200/300',
hidden
});
} catch (err) {
err.should.have.property('message', 'hidden is not defined');
}
});
or
it('tag + empty attr', function() {
try {
htmlTag('img', {
src: 'http://placekitten.com/200/300',
alt: null
});
} catch (err) {
err.should.have.property('message', 'alt is not defined');
}
});
2b5ce8e to
576289e
Compare
Author
|
Thinking it twice, just adding the conditions you suggested, all possible valid attributes are working as expected. I've added a few tests to ensure that works properly. |
Member
|
Could you please fix the error in travis-ci? |
576289e to
d05ba8b
Compare
Author
|
@NoahDragon should be fixed now |
Member
|
@Xaviju Great, thank you. |
2 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes this issue -> hexojs/hexo#3222