style: Treat empty root margin as zero as per spec

Differential Revision: https://phabricator.services.mozilla.com/D130131
This commit is contained in:
Emilio Cobos Álvarez 2023-05-30 20:43:32 +02:00 committed by Oriol Brufau
parent 285c645b78
commit 04776cd116

View file

@ -49,6 +49,11 @@ impl Parse for IntersectionObserverRootMargin {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
use crate::Zero;
if input.is_exhausted() {
// If there are zero elements in tokens, set tokens to ["0px"].
return Ok(IntersectionObserverRootMargin(Rect::all(LengthPercentage::zero())));
}
let rect = Rect::parse_with(context, input, parse_pixel_or_percent)?;
Ok(IntersectionObserverRootMargin(rect))
}