Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dcc-js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D-PTB
DCC
Development
dcc-js
Commits
5e9b2237
Verified
Commit
5e9b2237
authored
3 years ago
by
Jan Loewe
Browse files
Options
Downloads
Patches
Plain Diff
fix(xml): add workaround for element order
parent
e9052c8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DCCDocument.ts
+8
-4
8 additions, 4 deletions
src/DCCDocument.ts
with
8 additions
and
4 deletions
src/DCCDocument.ts
+
8
−
4
View file @
5e9b2237
...
@@ -32,10 +32,10 @@ export class DCCDocument {
...
@@ -32,10 +32,10 @@ export class DCCDocument {
ignoreComment
:
true
,
ignoreComment
:
true
,
trim
:
true
,
trim
:
true
,
attributesKey
:
"
_attr
"
,
attributesKey
:
"
_attr
"
,
elementNameFn
:
function
(
val
)
{
elementNameFn
:
function
(
val
)
{
return
val
.
replace
(
"
dcc:
"
,
""
).
replace
(
"
si:
"
,
""
);
return
val
.
replace
(
"
dcc:
"
,
""
).
replace
(
"
si:
"
,
""
);
},
},
textFn
:
function
(
val
)
{
textFn
:
function
(
val
)
{
return
val
return
val
.
split
(
"
\n
"
)
.
split
(
"
\n
"
)
.
map
((
x
)
=>
x
.
trim
())
.
map
((
x
)
=>
x
.
trim
())
...
@@ -47,12 +47,16 @@ export class DCCDocument {
...
@@ -47,12 +47,16 @@ export class DCCDocument {
}
}
toXML
():
string
{
toXML
():
string
{
return
js2xml
(
<
Element
>
this
,
{
/* Properties order in objects is not guaranteed in JavaScript.
* This is a workaround to fix this.
* The keys are set in the right order by creating a new instance of DCCDocument */
const
fixedOrderDoc
=
new
DCCDocument
(
this
);
return
js2xml
(
<
Element
>
fixedOrderDoc
,
{
compact
:
true
,
compact
:
true
,
ignoreComment
:
true
,
ignoreComment
:
true
,
spaces
:
2
,
spaces
:
2
,
attributesKey
:
"
_attr
"
,
attributesKey
:
"
_attr
"
,
elementNameFn
:
function
(
val
,
currentElementObj
)
{
elementNameFn
:
function
(
val
,
currentElementObj
)
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const
currentElement
=
<
any
>
currentElementObj
;
const
currentElement
=
<
any
>
currentElementObj
;
return
`
${
currentElement
?.
namespace
?
`
${
currentElement
.
namespace
}
:`
:
""
}${
val
}
`
;
return
`
${
currentElement
?.
namespace
?
`
${
currentElement
.
namespace
}
:`
:
""
}${
val
}
`
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment