Skip to content

Commit

Permalink
Resolve bug in Node.removeChild
Browse files Browse the repository at this point in the history
removeChild treated `children` as a List of nodes, rather than a
map of String,Node (nodeNames as the String). This meant trying
to remove the Node from the list would silently fail every call.
  • Loading branch information
butlermatt committed Oct 13, 2020
1 parent fc2c8ef commit 9755006
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ChangeLog

* v1.0.6 - Fix a logic error in removeChild method of Nodes.
* v1.0.5 - Ensure that QOS downgrades are propagated.
* v1.0.4+1 - Map logger names to match DSA log levels.
* v1.0.4 - Forward any errors generated by a `list` request to the requester.
Expand Down
9 changes: 7 additions & 2 deletions lib/src/common/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ class Node {
/// [input] can be either an instance of [Node] or a [String].
String removeChild(dynamic input) {
if (input is String) {
children.remove(getChild(input));
children.remove(input);
return input;
} else if (input is Node) {
children.remove(input);
for (var nodeName in children.keys.toList()) {
if ((input as Node) == children[nodeName]) {
children.remove(nodeName);
return nodeName;
}
}
} else {
throw new Exception("Invalid Input");
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dslink
version: 1.0.5
version: 1.0.6
description: "DSA IoT Platform - DSLink SDK for Dart"
homepage: "http://iot-dsa.org"
documentation: "https://iot-dsa.github.io/docs/sdks/dart/"
Expand Down

0 comments on commit 9755006

Please sign in to comment.