Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable setting attributes when building obj with array #625

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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