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

DOM: Fix sematics of ContainerBuilder.FromMap() #10

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

rkosegi
Copy link
Owner

@rkosegi rkosegi commented Apr 5, 2024

Up until this commit, FromMap() treated map keys as property paths,
which means ANY value is coerced into LeafNode.
More correct behavior is to not treat them as such, but pass them as-is
into existing code (appendMap). This will simplify code path and make
it more logical overall.

Previous behavior can be easily achieved to foreign callers using public API:

       c := dom.Builder().Container()
       for k, v := range in {
               c.AddValueAt(k, dom.LeafNode(v))
       }
       return c

Signed-off-by: Richard Kosegi richard.kosegi@gmail.com

Up until this commit, FromMap() treated map keys as property paths,
which means ANY value is coerced into LeafNode.
More correct behavior is to not treat them as such, but pass them as-is
into existing code (appendMap). This will simplify code path and make
it more logical overall.

Previous behavior can be easily achieved to foreign callers using public API:

```go
       c := dom.Builder().Container()
       for k, v := range in {
               c.AddValueAt(k, dom.LeafNode(v))
       }
       return c
```

Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@rkosegi rkosegi merged commit a6b517b into main Apr 5, 2024
2 checks passed
@rkosegi rkosegi deleted the bug/cont-build-from-map branch April 5, 2024 07:03
rkosegi added a commit that referenced this pull request May 17, 2024
Fix introduced in #10 changed FromMap() semantics,
which might still be desirable in some cases. Create factory method
FromProperties() that will use old way of initialising

Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
rkosegi added a commit that referenced this pull request May 17, 2024
Fix introduced in #10 changed FromMap() semantics,
which might still be desirable in some cases. Create factory method
FromProperties() that will use old way of initialising

Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
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