private static ICssStyleDeclaration CreateStyle(IElement element, String source) { var document = element.Owner; var context = document.Context; var style = new CssStyleDeclaration(context); style.Update(source ?? element.GetAttribute(AttributeNames.Style)); style.Changed += value => element.SetAttribute(AttributeNames.Style, value); return(style); }
private static ICssStyleDeclaration CreateStyle(IElement element, String source) { var document = element.Owner; var context = document.Context; var parser = context?.GetService <ICssParser>(); // Seems to be run from a context with CSS if (parser != null) { var style = new CssStyleDeclaration(context); style.Update(source ?? element.GetAttribute(AttributeNames.Style)); style.Changed += value => element.SetAttribute(AttributeNames.Style, value); return(style); } return(null); }