`attributesGroupName` writes `null` and `undefined` attribute values as text
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 83/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
src/fxb.jsから始め、170~183行目付近の個別キー属性の処理と、281~288行目付近のattributesGroupName分岐を比較してください。グループ化された属性に関する既存のテストを確認し、nullとundefinedの値を対象とするテストを追加してください。グループ化された属性と個別キー属性の両方でこれらの値が省かれ、残りの属性の出力が期待されるXMLと一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Version: 1.3.2
Context: I group attributes so that attribute keys don't need the @_ prefix and can't collide with child element names.
With attributesGroupName set, an attribute whose value is null or undefined is written as the text "null" or "undefined". Without a group name, the same values are left out.
Reproduction
import XMLBuilder from 'fast-xml-builder';
const perKey = new XMLBuilder({ ignoreAttributes: false });
console.log(perKey.build({ item: { '@_a': 'x', '@_b': null, '@_c': undefined } }));
// <item a="x"></item>
const grouped = new XMLBuilder({ ignoreAttributes: false, attributesGroupName: '$' });
console.log(grouped.build({ item: { $: { a: 'x', b: null, c: undefined } } }));
// <item a="x" b="null" c="undefined"></item>
Expected
Both print <item a="x"></item>.
Additional details
When building, the builder skips undefined and null values for individually keyed attributes (src/fxb.js#L170-L183), which came from NaturalIntelligence/fast-xml-parser#598 for NaturalIntelligence/fast-xml-parser#585. The attributesGroupName branch (src/fxb.js#L281-L288) passes every value in the group to buildAttrPairStr without that check. attributeValueProcessor can't drop an attribute, so no option works around it.
- 主要言語
- JavaScript
- スター
- 22
- フォーク
- 9
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NaturalIntelligence/fast-xml-builder のほかの issue
-
`preserveOrder: true` with `format: true` formats mixed content wrongly and adds whitespace to content that ends with `>`対応中かも @neumaennl が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
`XMLBuilder` object should be exported as a named export, not just the type対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NaturalIntelligence/fast-xml-builder#25 · コメント 1 件 ·
-
sanitizeName not applied to names inside stopNodes (quote injection / tag break-out bypass)対応中かも @hicay が 5 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
NaturalIntelligence/fast-xml-builder#34 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
NaturalIntelligence/fast-xml-builder#4 · コメント 5 件 · リアクション 2 件 ·
NaturalIntelligence/fast-xml-builder の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
Extended search drops any query term that contains a line break対応中かも @goranai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
area:mcp
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信