Skip to content

Commit 58f6965

Browse files
committed
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
1 parent 9202ae5 commit 58f6965

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

style/queries/feature_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl QueryStyleRange {
941941
QueryExpressionValue::Custom(ident) => {
942942
// `ident` is the dashed ident, but we need the name
943943
// without "--" for custom-property lookup.
944-
let name = Atom::from(&ident.0.as_slice()[2..]);
944+
let name = ident.undashed();
945945
let stylist = context
946946
.builder
947947
.stylist

style/values/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,20 @@ impl DashedIdent {
646646
pub fn is_empty(&self) -> bool {
647647
self.0 == atom!("")
648648
}
649+
650+
/// Returns an atom with the same value, but without the starting "--".
651+
///
652+
/// # Panics
653+
///
654+
/// Panics when used on the special `DashedIdent::empty()`.
655+
pub(crate) fn undashed(&self) -> Atom {
656+
assert!(!self.is_empty(), "Can't undash the empty DashedIdent");
657+
#[cfg(feature = "gecko")]
658+
let name = &self.0.as_slice()[2..];
659+
#[cfg(feature = "servo")]
660+
let name = &self.0[2..];
661+
Atom::from(name)
662+
}
649663
}
650664

651665
impl Parse for DashedIdent {

0 commit comments

Comments
 (0)