mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove some unnecessary uses of as_slice
For the majority of these cases, `as_slice` can be removed due to `Deref`. In particular, `Deref` for: * `String` -> `str` * `Atom` -> `str` The latter of those two requires, a bump of the locked `string-cache` library
This commit is contained in:
parent
b8ea10bfe3
commit
d838fcce30
19 changed files with 98 additions and 102 deletions
|
@ -146,7 +146,7 @@ pub trait HTMLElementCustomAttributeHelpers {
|
|||
|
||||
fn to_snake_case(name: DOMString) -> DOMString {
|
||||
let mut attr_name = "data-".to_owned();
|
||||
for ch in name.as_slice().chars() {
|
||||
for ch in name.chars() {
|
||||
if ch.is_uppercase() {
|
||||
attr_name.push('\x2d');
|
||||
attr_name.push(ch.to_lowercase());
|
||||
|
@ -170,7 +170,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> {
|
|||
|
||||
fn get_custom_attr(self, name: DOMString) -> Option<DOMString> {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
element.get_attribute(ns!(""), &Atom::from_slice(to_snake_case(name).as_slice())).map(|attr| {
|
||||
element.get_attribute(ns!(""), &Atom::from_slice(&to_snake_case(name))).map(|attr| {
|
||||
let attr = attr.root();
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
|
@ -181,7 +181,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> {
|
|||
|
||||
fn delete_custom_attr(self, name: DOMString) {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
element.remove_attribute(ns!(""), to_snake_case(name).as_slice())
|
||||
element.remove_attribute(ns!(""), &to_snake_case(name))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
|||
s.after_set_attr(attr);
|
||||
}
|
||||
|
||||
let name = attr.local_name().as_slice();
|
||||
let name = attr.local_name();
|
||||
if name.starts_with("on") {
|
||||
let window = window_from_node(*self).root();
|
||||
let (cx, url, reflector) = (window.r().get_cx(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue