feat: ability to specify if selfClosing element is a void element#670
feat: ability to specify if selfClosing element is a void element#670gastonyte wants to merge 8 commits intoapostrophecms:mainfrom
Conversation
|
I didn't change the documentation because I don't know where to write about |
boutell
left a comment
There was a problem hiding this comment.
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.
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.
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.
Use Object.hasOwn(options.selfClosing, name) to make sure it's a real property and not something sneaky like __prototype__. Or use a Map.
| options.parser = Object.assign({}, htmlParserDefaults, options.parser); | ||
|
|
||
| const tagAllowed = function (name) { | ||
| const { selfClosing } = options; |
There was a problem hiding this comment.
Localized and then never used in a localized away again because of the reassignment for the array case. So I think it would be clearer if we didn't do this at all and just referred to options.selfClosing throughout this bit.
There was a problem hiding this comment.
The README must be updated to cover this new syntax.
There was a problem hiding this comment.
Sorry for the delay on this one!
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Bump to remove label. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
I know this has been a long back and forth, but do you know if you will be able to finish this @gastonyte? |
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: