Skip to content

Commit

Permalink
Allow fragment urls in custom properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed May 23, 2022
1 parent c7a59e1 commit f6f1673
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17994,6 +17994,12 @@ mod tests {
".foo{behavior:url(\"Zn9-2q\")}",
vec![("#foo", "Zn9-2q")],
);

dep_test(
".foo { --foo: url(#foo) }",
".foo{--foo:url(\"Zn9-2q\")}",
vec![("#foo", "Zn9-2q")],
);
}

#[test]
Expand Down
7 changes: 7 additions & 0 deletions src/values/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ impl<'i> Url<'i> {
return true;
}

// If the url starts with '#' we have a fragment URL.
// These are resolved relative to the document rather than the CSS file.
// https://drafts.csswg.org/css-values-4/#local-urls
if url.starts_with('#') {
return true;
}

// Otherwise, we might have a scheme. These must start with an ascii alpha character.
// https://url.spec.whatwg.org/#scheme-start-state
if !url.starts_with(|c| matches!(c, 'a'..='z' | 'A'..='Z')) {
Expand Down

0 comments on commit f6f1673

Please sign in to comment.