@@ -112,9 +112,13 @@ impl FeatureToCss for ContainerSizeFeatureId {
112
112
) ]
113
113
#[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
114
114
pub enum StyleQuery < ' i > {
115
- /// A style feature, implicitly parenthesized .
115
+ /// A property declaration .
116
116
#[ cfg_attr( feature = "serde" , serde( borrow, with = "ValueWrapper::<Property>" ) ) ]
117
- Feature ( Property < ' i > ) ,
117
+ Declaration ( Property < ' i > ) ,
118
+ /// A property name, without a value.
119
+ /// This matches if the property value is different from the initial value.
120
+ #[ cfg_attr( feature = "serde" , serde( with = "ValueWrapper::<PropertyId>" ) ) ]
121
+ Property ( PropertyId < ' i > ) ,
118
122
/// A negation of a condition.
119
123
#[ cfg_attr( feature = "visitor" , skip_type) ]
120
124
#[ cfg_attr( feature = "serde" , serde( with = "ValueWrapper::<Box<StyleQuery>>" ) ) ]
@@ -170,11 +174,14 @@ impl<'i> QueryCondition<'i> for StyleQuery<'i> {
170
174
#[ inline]
171
175
fn parse_feature < ' t > ( input : & mut Parser < ' i , ' t > ) -> Result < Self , ParseError < ' i , ParserError < ' i > > > {
172
176
let property_id = PropertyId :: parse ( input) ?;
173
- input. expect_colon ( ) ?;
174
- input. skip_whitespace ( ) ;
175
- let feature = Self :: Feature ( Property :: parse ( property_id, input, & Default :: default ( ) ) ?) ;
176
- let _ = input. try_parse ( |input| parse_important ( input) ) ;
177
- Ok ( feature)
177
+ if input. try_parse ( |input| input. expect_colon ( ) ) . is_ok ( ) {
178
+ input. skip_whitespace ( ) ;
179
+ let feature = Self :: Declaration ( Property :: parse ( property_id, input, & Default :: default ( ) ) ?) ;
180
+ let _ = input. try_parse ( |input| parse_important ( input) ) ;
181
+ Ok ( feature)
182
+ } else {
183
+ Ok ( Self :: Property ( property_id) )
184
+ }
178
185
}
179
186
180
187
#[ inline]
@@ -191,7 +198,7 @@ impl<'i> QueryCondition<'i> for StyleQuery<'i> {
191
198
match self {
192
199
StyleQuery :: Not ( _) => true ,
193
200
StyleQuery :: Operation { operator, .. } => Some ( * operator) != parent_operator,
194
- StyleQuery :: Feature ( _) => true ,
201
+ StyleQuery :: Declaration ( _ ) | StyleQuery :: Property ( _) => true ,
195
202
}
196
203
}
197
204
}
@@ -232,7 +239,8 @@ impl<'i> ToCss for StyleQuery<'i> {
232
239
W : std:: fmt:: Write ,
233
240
{
234
241
match * self {
235
- StyleQuery :: Feature ( ref f) => f. to_css ( dest, false ) ,
242
+ StyleQuery :: Declaration ( ref f) => f. to_css ( dest, false ) ,
243
+ StyleQuery :: Property ( ref f) => f. to_css ( dest) ,
236
244
StyleQuery :: Not ( ref c) => {
237
245
dest. write_str ( "not " ) ?;
238
246
to_css_with_parens_if_needed ( & * * c, dest, c. needs_parens ( None , & dest. targets ) )
0 commit comments