Skip to content

Commit 0fff9d0

Browse files
committed
Merge branch '0.3.7release-cleanup'
2 parents 64fb47e + b5653e4 commit 0fff9d0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ in addition to semicolons
1313
- `Listener` now implements `MessageMapper`
1414
- `El methods` `add_child`, `add_style`, `add_attr`, and `set_text` now return the elements,
1515
allowing chaining
16-
- Fixed a bug with `set_text`. Renamed to `replace_text`. Aded `add_text`, which adds
17-
a text node, but doesn't remove existing ones. Added `add_class`.
16+
- Fixed a bug with `set_text`. Renamed to `replace_text`. Added `add_text`, which adds
17+
a text node, but doesn't remove existing ones. Added `add_class`. (Breaking)
1818

1919

2020
## v0.3.6

src/dom_types.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,11 @@ impl<Ms> El<Ms> {
850850
pub fn add_class(mut self, name: &str) -> Self {
851851
let mut updated = name.to_string();
852852
if let Some(names) = self.attrs.vals.get(&At::Class) {
853-
updated = names.clone() + " " + name;
853+
if names.is_empty() {
854+
updated = name.to_string();
855+
} else {
856+
updated = names.clone() + " " + name;
857+
}
854858
}
855859
self.attrs.vals.insert(At::Class, updated);
856860
self
@@ -862,7 +866,8 @@ impl<Ms> El<Ms> {
862866
self
863867
}
864868

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

0 commit comments

Comments
 (0)