Don't create text node for self closing tags when `alwaysCreateTextNode: true`
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- tooling
Research direction
No source file or test is named. Start by reproducing both parser.parse examples with alwaysCreateTextNode enabled, then trace the self-closing-tag handling from the parser.parse entry point. Done should be confirmed by tests covering self-closing tags with and without attributes and the intended text-node behavior.
Written by the indexing model from the issue text.
Description
Currently I can have the parser create a text node on tags without attributes by setting alwaysCreateTextNode: true. However, for self closing tags, I would like the parser to not create a text node. Right now it creates a text node set to an empty string.
I also noticed that if a self closing tags have any attributes, a text node is not created. It only seems like it's created when a self closing tags have no attributes.
// Given these settings:
const parser = new XMLParser({
ignoreAttributes: false,
allowBooleanAttributes: true,
parseTagValue: false,
alwaysCreateTextNode: true,
});
parser.parse("<workbookPr defaultThemeVersion="153222" />")
// "workbookPr": {
// "@_defaultThemeVersion": "153222"
// }
parser.parse("<workbookPr />")
// "workbookPr": {
// "#text": ""
// }
I expect that "#text" is always present, no matter if the self closing tag have attributes or not. But my primary expectation is to be able to have no text nodes at all for self closing tags while still allowing the parser to make text nodes for tags without any attributes.
- Dominant language
- JavaScript
- Stars
- 3.1k
- Forks
- 398
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NaturalIntelligence/fast-xml-parser
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 comments ·
Maintainers usually reply within 2 days
-
ignoreDeclaration does not ignore lower case doctype declarationMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 comments ·
Maintainers usually reply within 2 days
-
Enhance type definition for XMLParser `isArray` option when using TypeScriptMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
NaturalIntelligence/fast-xml-parser#803 · 21 comments · 2 reactions ·
Maintainers usually reply within 2 days
-
Feature-Request
Difficulty 4/5 3-5 days Newbie friendliness 52/100
NaturalIntelligence/fast-xml-parser#779 · 9 comments ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
NaturalIntelligence/fast-xml-parser#766 · 4 comments ·
Maintainers usually reply within 2 days
All issues in NaturalIntelligence/fast-xml-parser
Similar issues
-
[Bug] Dev image build fails: `npm install` in the root Dockerfile runs out of memory (exit 134)Possibly taken @andest01 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
good first issue hacktoberfest help wanted
Difficulty 2/5 Under an hour Newbie friendliness 76/100
pacocartones/free-llm-api-hub#262 ·
Maintainers usually reply within 1 day
-
agent-task risk:low
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
guyellis/http-status-check#512 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/playwright#43327 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64758 ·
Maintainers usually reply within 1 day