Apply new Clippy lints, examples deployment, and stdweb integration tests (#1651)

* make clippy happy

* fix publish-examples workflow

* disable yew-stdweb integration tests on stable
This commit is contained in:
Simon 2020-11-22 22:50:33 +01:00 committed by GitHub
parent efd8547ef0
commit c72d990bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 234 additions and 212 deletions

View File

@ -31,8 +31,7 @@ jobs:
- name: Install trunk
run: |
brew install trunk
cargo install wasm-bindgen-cli
cargo install trunk wasm-bindgen-cli
- name: Build examples
run: |

View File

@ -174,6 +174,7 @@ jobs:
wasm-pack test --chrome --firefox --headless -- --features "wasm_test httpbin_test"
- name: Run tests - yew-stdweb
if: matrix.toolchain != 'stable'
env:
HTTPBIN_URL: "http://localhost:8080"
run: |

View File

@ -161,7 +161,7 @@ fn make_tag(t: Tag) -> VTag {
let mut el = VTag::new("a");
el.add_attribute("href", href.to_string());
let title = title.clone().into_string();
if title != "" {
if !title.is_empty() {
el.add_attribute("title", title);
}
el
@ -170,7 +170,7 @@ fn make_tag(t: Tag) -> VTag {
let mut el = VTag::new("img");
el.add_attribute("src", src.to_string());
let title = title.clone().into_string();
if title != "" {
if !title.is_empty() {
el.add_attribute("title", title);
}
el

View File

@ -1,7 +1,6 @@
use super::{Prop, Props, SpecialProps};
use lazy_static::lazy_static;
use std::collections::HashSet;
use std::iter::FromIterator;
use syn::parse::{Parse, ParseStream};
use syn::{Expr, ExprTuple};
@ -93,7 +92,6 @@ impl Parse for ElementProps {
lazy_static! {
static ref BOOLEAN_SET: HashSet<&'static str> = {
HashSet::from_iter(
vec![
"async",
"autofocus",
@ -112,14 +110,13 @@ lazy_static! {
"required",
"selected",
]
.into_iter(),
)
.into_iter()
.collect()
};
}
lazy_static! {
static ref LISTENER_SET: HashSet<&'static str> = {
HashSet::from_iter(
vec![
// Living Standard
// From: https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
@ -224,15 +221,14 @@ lazy_static! {
"ontransitionrun",
"ontransitionstart",
]
.into_iter(),
)
.into_iter()
.collect()
};
}
#[cfg(feature = "std_web")]
lazy_static! {
static ref UNSUPPORTED_LISTENER_SET: HashSet<&'static str> = {
HashSet::from_iter(
vec![
"oncancel",
"oncanplay",
@ -275,7 +271,7 @@ lazy_static! {
"ontransitionrun",
"ontransitionstart",
]
.into_iter(),
)
.into_iter()
.collect()
};
}

View File

@ -39,11 +39,10 @@ impl<'a> fmt::Debug for PrettyParseError<'a> {
f.write_str("Expected: ")?;
self.error.expected[..self.error.expected.len() - 1]
.iter()
.map(|expected| {
.try_for_each(|expected| {
<ExpectedToken as fmt::Display>::fmt(expected, f)
.and_then(|_| f.write_str(", "))
})
.collect::<Result<(), fmt::Error>>()?;
})?;
self.error
.expected
.last()

View File

@ -139,11 +139,11 @@ impl<U: Switch + std::fmt::Debug> Switch for AllowMissing<U> {
if inner.is_some() {
(Some(AllowMissing(inner)), inner_state)
} else if &route == ""
|| (&route).starts_with('/')
|| (&route).starts_with('?')
|| (&route).starts_with('&')
|| (&route).starts_with('#')
} else if route.is_empty()
|| route.starts_with('/')
|| route.starts_with('?')
|| route.starts_with('&')
|| route.starts_with('#')
{
(Some(AllowMissing(None)), inner_state)
} else {

View File

@ -19,16 +19,45 @@ fn is_c0_control(c: char) -> bool {
/// Returns true when the string provided is a "noncharacter" as defined
/// in [the WhatWG spec](https://infra.spec.whatwg.org/#noncharacter)
fn is_noncharacter(c: char) -> bool {
match c {
'\u{FDD0}'..='\u{FDEF}' => true,
'\u{FFFE}' | '\u{FFFF}' | '\u{1FFFE}' | '\u{1FFFF}' | '\u{2FFFE}' | '\u{2FFFF}'
| '\u{3FFFE}' | '\u{3FFFF}' | '\u{4FFFE}' | '\u{4FFFF}' | '\u{5FFFE}' | '\u{5FFFF}'
| '\u{6FFFE}' | '\u{6FFFF}' | '\u{7FFFE}' | '\u{7FFFF}' | '\u{8FFFE}' | '\u{8FFFF}'
| '\u{9FFFE}' | '\u{9FFFF}' | '\u{AFFFE}' | '\u{AFFFF}' | '\u{BFFFE}' | '\u{BFFFF}'
| '\u{CFFFE}' | '\u{CFFFF}' | '\u{DFFFE}' | '\u{DFFFF}' | '\u{EFFFE}' | '\u{EFFFF}'
| '\u{FFFFE}' | '\u{FFFFF}' | '\u{10FFFE}' | '\u{10FFFF}' => true,
_ => false,
}
matches!(
c,
'\u{FDD0}'
..='\u{FDEF}'
| '\u{FFFE}'
| '\u{FFFF}'
| '\u{1FFFE}'
| '\u{1FFFF}'
| '\u{2FFFE}'
| '\u{2FFFF}'
| '\u{3FFFE}'
| '\u{3FFFF}'
| '\u{4FFFE}'
| '\u{4FFFF}'
| '\u{5FFFE}'
| '\u{5FFFF}'
| '\u{6FFFE}'
| '\u{6FFFF}'
| '\u{7FFFE}'
| '\u{7FFFF}'
| '\u{8FFFE}'
| '\u{8FFFF}'
| '\u{9FFFE}'
| '\u{9FFFF}'
| '\u{AFFFE}'
| '\u{AFFFF}'
| '\u{BFFFE}'
| '\u{BFFFF}'
| '\u{CFFFE}'
| '\u{CFFFF}'
| '\u{DFFFE}'
| '\u{DFFFF}'
| '\u{EFFFE}'
| '\u{EFFFF}'
| '\u{FFFFE}'
| '\u{FFFFF}'
| '\u{10FFFE}'
| '\u{10FFFF}'
)
}
/// Returns true when the string provided is a valid "attribute name" as defined
@ -53,23 +82,21 @@ pub fn is_valid_html_attribute_name(attr: &str) -> bool {
/// Returns true when the character provided is a valid PCENChar as defined
/// in [the WhatWG spec](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-pcenchar)
fn is_pcen_char(c: char) -> bool {
match c {
'-' | '.' | '0'..='9' | 'a'..='z' | '_' => true,
'\u{B7}' => true,
'\u{C0}'..='\u{D6}' => true,
'\u{D8}'..='\u{F6}' => true,
'\u{F8}'..='\u{37D}' => true,
'\u{37F}'..='\u{1FFF}' => true,
'\u{200C}'..='\u{200D}' => true,
'\u{203F}'..='\u{2040}' => true,
'\u{2070}'..='\u{218F}' => true,
'\u{2C00}'..='\u{2FEF}' => true,
'\u{3001}'..='\u{D7FF}' => true,
'\u{F900}'..='\u{FDCF}' => true,
'\u{FDF0}'..='\u{FFFD}' => true,
'\u{10000}'..='\u{EFFFF}' => true,
_ => false,
}
matches!(c, '-' | '.' | '0'..='9' | 'a'..='z' | '_'
| '\u{B7}'
| '\u{C0}'..='\u{D6}'
| '\u{D8}'..='\u{F6}'
| '\u{F8}'..='\u{37D}'
| '\u{37F}'..='\u{1FFF}'
| '\u{200C}'..='\u{200D}'
| '\u{203F}'..='\u{2040}'
| '\u{2070}'..='\u{218F}'
| '\u{2C00}'..='\u{2FEF}'
| '\u{3001}'..='\u{D7FF}'
| '\u{F900}'..='\u{FDCF}'
| '\u{FDF0}'..='\u{FFFD}'
| '\u{10000}'..='\u{EFFFF}'
)
}
/// Returns true when the tag name provided would be a valid "custom element" per
@ -93,7 +120,7 @@ fn is_valid_html_custom_element_name(tag: &str) -> bool {
None => false,
Some(first_char) => {
// must begin with [a-z]
if first_char < 'a' || first_char > 'z' {
if !('a'..='z').contains(&first_char) {
return false;
}