-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat(parser): add support for custom selfClosing
tags
#21
Conversation
5450fcf
to
b607349
Compare
b607349
to
0967b7f
Compare
I could also add support for |
lib/parser.js
Outdated
|
||
const result = [] | ||
|
||
const selfClosing = SELF_CLOSING.concat(options.tags || []) |
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.
Relevant
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.
no, you need to add a parameter check if selfClosing
in tree
, andthe does not have tag
has a closing slash andcontent
<customTag />
tag: 'customTag'
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.
I'm not sure I fully understand, are you suggesting to add a selfClosing
prop to the node
instead ?
{
tag: 'import'
selfClosing: true // <=
attrs: { ... }
}
?
The SELF_CLOSING
list of tags might be unneeded here, I definitely need to revisit this once more, maybe I mixed things up here 😛 and we only need to check the node shape
to not have any content
, like you suggested
lib/parser.js
Outdated
'source', | ||
'track', | ||
'wbr', | ||
// Custom (PostHTML) |
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.
Relevant (include
might be needed to be removed for now, since this eventually could break existing code)
lib/parser.js
Outdated
}) | ||
} | ||
|
||
if (selfClosing.indexOf(tag) > -1) { |
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.
Relevant
lib/parser.js
Outdated
|
||
if (!buffer.length) { | ||
// undefined for selfClosing tags | ||
if (node) { |
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.
Relevant
The |
|
expect(parser(options)(fixture)).to.eql(expected) | ||
}) | ||
|
||
it('selfClosing', function () { |
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.
What is being tested?
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.
#21 (diff), but I need to revisit this PR one more time (today) anyways, currently working on finishing/updating posthtml/posthtml-include#16 so this can finally land soon :)
tags
option (options.tags
)selfClosing
tags
@gitscrum I removed the |
b4ea6ba
to
0df9c8c
Compare
0df9c8c
to
b5f1625
Compare
Any progress? |
@laosb Hi, something specific interests you from this PR ? |
@Scrum Can this be fast tracked please? Parcel Bundler uses |
@andrewbanchich Hi, describe the case that breaks your build |
Any tags that are self-closing don't output correctly. For Vue components, I'll often have |
What is the incorrectness? |
Looks like this setting fixed it: parcel-bundler/parcel#1103 (comment) Thanks though! |
Notable Changes
selfClosing
tagsBREAKING CHANGES
node < v4.0.0
parser
is curriedIssues
PR's
Closes Milestone 0.3.1 #19htmlparser2/lib/Parser
directly #20