GetPropertyValue() public method

Used to retrieve the value of a CSS property if it has been explicitly set within this declaration block.
public GetPropertyValue ( string propertyName ) : string
propertyName string The name of the CSS property. See the CSS property index.
return string
Exemplo n.º 1
0
        public void TestNoInherit()
        {
            CssStyleDeclaration csd = getStyles("<a />", "a{foo:bar;runar:'carola';}", "a");

            Assert.AreEqual("bar", csd.GetPropertyValue("foo"));
            Assert.AreEqual("\"carola\"", csd.GetPropertyValue("runar"));
        }
Exemplo n.º 2
0
        public void TestSimple()
        {
            CssStyleDeclaration csd = getStyles("<a />", "root{inher:12px} a{not:bar;}", "a");

            Assert.AreEqual("bar", csd.GetPropertyValue("not"));
            Assert.AreEqual("12px", csd.GetPropertyValue("inher"));
        }
Exemplo n.º 3
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", "");
        }
Exemplo n.º 4
0
        public void TestNonInherit()
        {
            CssStyleDeclaration csd = getStyles("<a />", "root{not:12px} a{}", "a");

            Assert.AreEqual("init", csd.GetPropertyValue("not"));
        }