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);
        }
예제 #2
0
        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);
        }