mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Remove usage of unstable feature ascii_ctypes
This commit is contained in:
parent
cbcc7d0802
commit
4ee8f56b9c
2 changed files with 11 additions and 4 deletions
|
@ -375,11 +375,19 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
static DATA_PREFIX: &str = "data-";
|
static DATA_PREFIX: &str = "data-";
|
||||||
static DATA_HYPHEN_SEPARATOR: char = '\x2d';
|
static DATA_HYPHEN_SEPARATOR: char = '\x2d';
|
||||||
|
|
||||||
|
fn is_ascii_uppercase(c: char) -> bool {
|
||||||
|
'A' <= c && c <= 'Z'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_ascii_lowercase(c: char) -> bool {
|
||||||
|
'a' <= c && c <= 'w'
|
||||||
|
}
|
||||||
|
|
||||||
fn to_snake_case(name: DOMString) -> DOMString {
|
fn to_snake_case(name: DOMString) -> DOMString {
|
||||||
let mut attr_name = String::with_capacity(name.len() + DATA_PREFIX.len());
|
let mut attr_name = String::with_capacity(name.len() + DATA_PREFIX.len());
|
||||||
attr_name.push_str(DATA_PREFIX);
|
attr_name.push_str(DATA_PREFIX);
|
||||||
for ch in name.chars() {
|
for ch in name.chars() {
|
||||||
if ch.is_ascii_uppercase() {
|
if is_ascii_uppercase(ch) {
|
||||||
attr_name.push(DATA_HYPHEN_SEPARATOR);
|
attr_name.push(DATA_HYPHEN_SEPARATOR);
|
||||||
attr_name.push(ch.to_ascii_lowercase());
|
attr_name.push(ch.to_ascii_lowercase());
|
||||||
} else {
|
} else {
|
||||||
|
@ -400,7 +408,7 @@ fn to_camel_case(name: &str) -> Option<DOMString> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let name = &name[5..];
|
let name = &name[5..];
|
||||||
let has_uppercase = name.chars().any(|curr_char| curr_char.is_ascii_uppercase());
|
let has_uppercase = name.chars().any(|curr_char| is_ascii_uppercase(curr_char));
|
||||||
if has_uppercase {
|
if has_uppercase {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +418,7 @@ fn to_camel_case(name: &str) -> Option<DOMString> {
|
||||||
//check for hyphen followed by character
|
//check for hyphen followed by character
|
||||||
if curr_char == DATA_HYPHEN_SEPARATOR {
|
if curr_char == DATA_HYPHEN_SEPARATOR {
|
||||||
if let Some(next_char) = name_chars.next() {
|
if let Some(next_char) = name_chars.next() {
|
||||||
if next_char.is_ascii_lowercase() {
|
if is_ascii_lowercase(next_char) {
|
||||||
result.push(next_char.to_ascii_uppercase());
|
result.push(next_char.to_ascii_uppercase());
|
||||||
} else {
|
} else {
|
||||||
result.push(curr_char);
|
result.push(curr_char);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#![feature(ascii_ctype)]
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue