mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Added in-place mutation to DOMString.
The methods which are currently implemented are the ones on String that are currently being used: string.push_str(...), string.clear() and string.extend(...). We may want to revisit this API.
This commit is contained in:
parent
034769f280
commit
5db67b5981
5 changed files with 23 additions and 5 deletions
|
@ -69,6 +69,7 @@ impl CharacterDataMethods for CharacterData {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-characterdata-appenddatadata
|
||||
fn AppendData(&self, data: DOMString) {
|
||||
// FIXME(ajeffrey): Efficient append on DOMStrings?
|
||||
self.append_data(&*data);
|
||||
}
|
||||
|
||||
|
@ -149,7 +150,8 @@ impl CharacterData {
|
|||
}
|
||||
#[inline]
|
||||
pub fn append_data(&self, data: &str) {
|
||||
self.data.borrow_mut().0.push_str(data);
|
||||
// FIXME(ajeffrey): Efficient append on DOMStrings?
|
||||
self.data.borrow_mut().push_str(data);
|
||||
self.content_changed();
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>) {
|
|||
// Step 6.
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=28925
|
||||
if let Some(suffix) = hyperlink_suffix {
|
||||
href.0.push_str(&suffix);
|
||||
href.push_str(&suffix);
|
||||
}
|
||||
|
||||
// Step 4-5.
|
||||
|
|
|
@ -576,10 +576,11 @@ impl VirtualMethods for HTMLInputElement {
|
|||
mutation.new_value(attr).as_ref().map(|name| name.as_atom()));
|
||||
},
|
||||
&atom!(placeholder) => {
|
||||
// FIXME(ajeffrey): Should we do in-place mutation of the placeholder?
|
||||
let mut placeholder = self.placeholder.borrow_mut();
|
||||
placeholder.0.clear();
|
||||
placeholder.clear();
|
||||
if let AttributeMutation::Set(_) = mutation {
|
||||
placeholder.0.extend(
|
||||
placeholder.extend(
|
||||
attr.value().chars().filter(|&c| c != '\n' && c != '\r'));
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue