Replace Namespace components which map to the default namespace with 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
This commit is contained in:
Jonathan Chan 2017-06-07 17:44:43 -07:00
parent 8e14d93602
commit bd5ff3b4ce

View file

@ -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)