Skip to content

Exclude use tag when routing #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added trait `UpdateElForIterator<Ms>`.
- Added support for all `Iterator`s, `Option`, `u32`, `i32`, `usize`, `f64` and references in element creation macros (#365, #128).
- [BREAKING] `String` implements `UpdateEl<T>`. (References are now required for `String` properties, e.g. `div![&model.title]`.)
- Fixed `href` detection to ignore `use` elements (#384).

## v0.6.0
- Implemented `UpdateEl` for `Filter` and `FilterMap`.
Expand Down
10 changes: 5 additions & 5 deletions src/browser/service/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::super::{
util::{self, ClosureNew},
Url,
};
use std::convert::{identity, TryFrom, TryInto};
use std::convert::{TryFrom, TryInto};
use wasm_bindgen::{closure::Closure, JsCast, JsValue};

/// Add a new route using history's `push_state` method.
Expand Down Expand Up @@ -114,10 +114,10 @@ where
event.target()
.and_then(|et| et.dyn_into::<web_sys::Element>().ok())
.and_then(|el| el.closest("[href]").ok())
.and_then(identity) // Option::flatten not stable (https://github.com/rust-lang/rust/issues/60258)
.and_then(|href_el| match href_el.tag_name().as_str() {
// Base and Link tags use href for something other than navigation.
"Base" | "Link" => None,
.flatten()
.and_then(|href_el| match href_el.tag_name().to_lowercase().as_str() {
// Base, Link and Use tags use href for something other than navigation.
"base" | "link" | "use" => None,
_ => Some(href_el)
})
.and_then(|href_el| href_el.get_attribute("href"))
Expand Down