Skip to content

Commit

Permalink
Merge pull request #167 from SmedbergM/fixUpdateWith
Browse files Browse the repository at this point in the history
[Issue #166] Make ScalaElement.updateWith(x) remove properties which …
  • Loading branch information
mpollmeier committed Aug 20, 2016
2 parents 30a8b63 + c87b542 commit d3fb15f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ trait ScalaElement[ElementType <: Element] {

def updateWith[CC <: Product: Marshallable](update: CC): ElementType = {
val propMap = implicitly[Marshallable[CC]].fromCC(update).valueMap
propMap foreach {case (prop, value) => element.property(prop, value)}
this.valueMap.keySet.diff(propMap.keySet) foreach { key =>
val prop = element.property(key)
if (prop.isPresent) prop.remove()
}
propMap foreach {case (key, value) => element.property(key, value)}

element
}
Expand Down

0 comments on commit d3fb15f

Please sign in to comment.