MediaList for linked stylesheet defaults to none instead of all
spriest487 opened this issue · comments
Hi, first of all thank you for this project, I've only just started using it but it's a huge help.
I'm trying to load a document which has a stylesheet linked like so:
<link href="style.css" rel="stylesheet">
But calling GetComputedStyle
on any element was returning nothing but the default styles. After some debugging I tracked it down the media type check - the medium for this loaded stylesheet was "all" but the IsInverse
flag on the medium is true, so it's never valid.
I think the problem might be this line in StyleSheetRequestProcessor.cs
where the default for a link with no explicit media type is set to the empty string:
sheet.Media.MediaText = _link.Media ?? String.Empty;
While in MediaList.cs
, the type only uses the default of "all" if the value passed in is actually null:
var media = MediaParser.Parse(value ?? CssKeywords.All, ValidatorFactory);
It seems like perhaps this check should be for null or an empty string, or maybe that StyleSheetRequestProcessor
should pass in a null
when no value is present?
Thanks for your time!