Skip to content

Commit

Permalink
Replace Namespace components which map to the default namespace with …
Browse files Browse the repository at this point in the history
…DefaultNamespace.

It seems we don't need to preserve the original prefix name, and this
conveniently leads to_css to now implement CSSOM's requirement to elide
the namespace prefix during serialization when it maps to the default
namespace.

https://drafts.csswg.org/cssom/#serialize-a-simple-selector
  • Loading branch information
jyc committed Jul 14, 2017
1 parent 8e14d93 commit bd5ff3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/selectors/parser.rs
Expand Up @@ -1017,7 +1017,10 @@ fn parse_type_selector<'i, 't, P, E, Impl, S>(parser: &P, input: &mut CssParser<
sink.push(Component::DefaultNamespace(url))
}
QNamePrefix::ExplicitNamespace(prefix, url) => {
sink.push(Component::Namespace(prefix, url))
sink.push(match parser.default_namespace() {
Some(ref default_url) if url == *default_url => Component::DefaultNamespace(url),
_ => Component::Namespace(prefix, url),
})
}
QNamePrefix::ExplicitNoNamespace => {
sink.push(Component::ExplicitNoNamespace)
Expand Down

0 comments on commit bd5ff3b

Please sign in to comment.