-
Notifications
You must be signed in to change notification settings - Fork 353
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: ability to specify if selfClosing element is a void element #670
base: main
Are you sure you want to change the base?
Conversation
I didn't change the documentation because I don't know where to write about |
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 is great — just one request to avoid prototype pollution issues.
As for documentation, please introduce a new third-level heading.
index.js
Outdated
const tagAllowed = function (name) { | ||
const { selfClosing } = options; | ||
if (Array.isArray(selfClosing)) { | ||
options.selfClosing = selfClosing.reduce((before, tagName) => ({ |
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 would be more performant to use a for loop here, avoiding the need to make a new object on every pass.
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 replaced the reduce with a for-of loop
index.js
Outdated
if (options.selfClosing.indexOf(name) !== -1) { | ||
result += ' />'; | ||
|
||
if (options.selfClosing[name]) { |
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.
Use Object.hasOwn(options.selfClosing, name)
to make sure it's a real property and not something sneaky like __prototype__
. Or use a Map
.
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.
done
Summary
That PR is about adding ability for users to not add a
/
at the end of specific void elements (like<br>
,<link>
or<input>
elements)This change originally come from #51
What are the specific steps to test this change?
What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: