Skip to content

Commit

Permalink
fix function on utf8 string, pass two tests
Browse files Browse the repository at this point in the history
dom/nodes/Node-properties.html
detachedForeignComment.length]
detachedXmlComment.length]
  • Loading branch information
yodalee committed Feb 28, 2015
1 parent e45b104 commit 0e29eab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 5 additions & 5 deletions components/script/dom/characterdata.rs
Expand Up @@ -77,11 +77,11 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
}

fn Length(self) -> u32 {
self.data.borrow().len() as u32
self.data.borrow().chars().count() as u32
}

fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> {
Ok(self.data.borrow()[offset as usize .. count as usize].to_owned())
Ok(self.data.borrow().slice_chars(offset as usize, (offset + count) as usize).to_owned())
}

fn AppendData(self, arg: DOMString) -> ErrorResult {
Expand All @@ -98,7 +98,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
}

fn ReplaceData(self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
let length = self.data.borrow().len() as u32;
let length = self.data.borrow().chars().count() as u32;
if offset > length {
return Err(IndexSize);
}
Expand All @@ -107,9 +107,9 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
} else {
count
};
let mut data = self.data.borrow()[..offset as usize].to_owned();
let mut data = self.data.borrow().slice_chars(0, offset as usize).to_owned();
data.push_str(arg.as_slice());
data.push_str(&self.data.borrow()[(offset + count) as usize..]);
data.push_str(&self.data.borrow().slice_chars((offset + count) as usize, length as usize));
*self.data.borrow_mut() = data;
// FIXME: Once we have `Range`, we should implement step7 to step11
Ok(())
Expand Down
6 changes: 0 additions & 6 deletions tests/wpt/metadata/dom/nodes/Node-properties.html.ini
Expand Up @@ -132,12 +132,6 @@
[detachedXmlTextNode.wholeText]
expected: FAIL

[detachedForeignComment.length]
expected: FAIL

[detachedXmlComment.length]
expected: FAIL

[paras[0\].previousElementSibling]
expected: FAIL

Expand Down

5 comments on commit 0e29eab

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at yodalee@0e29eab

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging yodalee/servo/issue4906-fix-characterdata-substringdata = 0e29eab into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yodalee/servo/issue4906-fix-characterdata-substringdata = 0e29eab merged ok, testing candidate = 55f7636

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 55f7636

Please sign in to comment.