Skip to content

Commit

Permalink
Merge branch '0.3.7release-cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed Jun 22, 2019
2 parents 64fb47e + b5653e4 commit 0fff9d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ in addition to semicolons
- `Listener` now implements `MessageMapper`
- `El methods` `add_child`, `add_style`, `add_attr`, and `set_text` now return the elements,
allowing chaining
- Fixed a bug with `set_text`. Renamed to `replace_text`. Aded `add_text`, which adds
a text node, but doesn't remove existing ones. Added `add_class`.
- Fixed a bug with `set_text`. Renamed to `replace_text`. Added `add_text`, which adds
a text node, but doesn't remove existing ones. Added `add_class`. (Breaking)


## v0.3.6
Expand Down
9 changes: 7 additions & 2 deletions src/dom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,11 @@ impl<Ms> El<Ms> {
pub fn add_class(mut self, name: &str) -> Self {
let mut updated = name.to_string();
if let Some(names) = self.attrs.vals.get(&At::Class) {
updated = names.clone() + " " + name;
if names.is_empty() {
updated = name.to_string();
} else {
updated = names.clone() + " " + name;
}
}
self.attrs.vals.insert(At::Class, updated);
self
Expand All @@ -862,7 +866,8 @@ impl<Ms> El<Ms> {
self
}

/// Add a text node to the element. (ie between the HTML tags)
/// Add a text node to the element. (ie between the HTML tags).
/// Removes all text nodes from element, then adds the new one.
pub fn add_text(mut self, text: &str) -> Self {
// todo: Allow text to be impl ToString?
self.children.push(El::new_text(text));
Expand Down

0 comments on commit 0fff9d0

Please # to comment.