Skip to content

Conversation

jansule
Copy link

@jansule jansule commented Aug 16, 2021

This solves #624

This allows setting attributes on parent elements, while preserving the order of its children, when using builder.buildObject().

I know this is some rather hakish code, as we are setting properties on an array, but I don't see any other way of providing this functionality. Please let me know, if we should follow a different approach here.

Example:

let children = [{Literal: 'foo'}, {PropertyName: 'bar'}, {Literal: 'baz'}];
children.$ = {name: 'faz'};
builder.buildObject({Parent: [children]});

leads to following result:

<Parent name="faz">
  <Literal>foo<Literal>
  <PropertyName>bar</PropertyName>
  <Literal>baz<Literal>
</Parent>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant