GetPropertyPriority() public method

Used to retrieve the priority of a CSS property (e.g. the "important" qualifier) if the property has been explicitly set in this declaration block.
public GetPropertyPriority ( string propertyName ) : string
propertyName string The name of the CSS property. See the CSS property index.
return string
示例#1
0
        public void TestCssStyleDeclaration()
        {
            rule = (CssStyleRule)cssStyleSheet.CssRules[0];
            CssStyleDeclaration csd = (CssStyleDeclaration)rule.Style;

            Assert.AreEqual("fill:#123456 !important;opacity:0.5;", csd.CssText);
            Assert.AreEqual(2, csd.Length);
            Assert.AreSame(rule, csd.ParentRule);
            Assert.AreEqual("important", csd.GetPropertyPriority("fill"));
            Assert.AreEqual("0.5", csd.GetPropertyValue("opacity"));
            Assert.AreEqual("", csd.GetPropertyPriority("opacity"));
            Assert.AreEqual("#123456", csd.GetPropertyValue("fill"));

            csd.SetProperty("opacity", "0.8", "");
            Assert.AreEqual("0.8", csd.GetPropertyValue("opacity"));
            Assert.AreEqual("", csd.GetPropertyPriority("opacity"));

            csd.SetProperty("opacity", "0.2", "important");
            Assert.AreEqual("0.2", csd.GetPropertyValue("opacity"));
            Assert.AreEqual("important", csd.GetPropertyPriority("opacity"));

            Assert.AreEqual("0.2", csd.RemoveProperty("opacity"));
            Assert.AreEqual(1, csd.Length);

            csd.SetProperty("foo", "bar", "");
            Assert.AreEqual("bar", csd.GetPropertyValue("foo"));
            Assert.AreEqual(2, csd.Length);

            // reset values
            csd.RemoveProperty("foo");
            csd.SetProperty("opacity", "0.5", "");
        }