[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] SF.net SVN: htmlunit:[6729] trunk/htmlunit/src
From:       rbri () users ! sourceforge ! net
Date:       2012-01-26 19:46:12
Message-ID: E1RqVGu-0002Zu-M0 () sfp-svn-6 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 6729
          http://htmlunit.svn.sourceforge.net/htmlunit/?rev=6729&view=rev
Author:   rbri
Date:     2012-01-26 19:46:12 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
CSSStyleDeclaration.removeProperty is now available in FF mode.

Modified Paths:
--------------
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java
  trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml
  trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java


Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml	2012-01-25 16:01:53 UTC (rev 6728)
+++ trunk/htmlunit/src/changes/changes.xml	2012-01-26 19:46:12 UTC (rev 6729)
@@ -6,6 +6,9 @@
 
     <body>
         <release version="2.10" date="???" description="Bugfixes">
+            <action type="fix" dev="rbri">
+                JavaScript: CSSStyleDeclaration.removeProperty is now available in \
FF mode. +            </action>
             <action type="fix" dev="rbri" issue="3475974">
                 Some not needed exception declarations are gone.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java	2012-01-25 \
                16:01:53 UTC (rev 6728)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java	2012-01-26 \
19:46:12 UTC (rev 6729) @@ -559,21 +559,22 @@
     }
 
     /**
-     * Removes the specified style attribute, returning the element index of the \
removed attribute. +     * Removes the specified style attribute, returning the value \
                of the removed attribute.
      * @param name the attribute name (delimiter-separated, not camel-cased)
      */
-    private void removeStyleAttribute(final String name) {
+    private String removeStyleAttribute(final String name) {
         if (null != styleDeclaration_) {
-            styleDeclaration_.removeProperty(name);
-            return;
+            return styleDeclaration_.removeProperty(name);
         }
 
         final Map<String, StyleElement> styleMap = getStyleMap();
-        if (!styleMap.containsKey(name)) {
-            return;
+        final StyleElement value = styleMap.get(name);
+        if (value == null) {
+            return "";
         }
         styleMap.remove(name);
         writeToElement(styleMap);
+        return value.getValue();
     }
 
     /**
@@ -4686,6 +4687,15 @@
     }
 
     /**
+     * Removes the named property.
+     * @param name the name of the property to remove
+     * @return the value deleted
+     */
+    public String jsxFunction_removeProperty(final String name) {
+        return removeStyleAttribute(name);
+    }
+
+    /**
      * Sets an expression for the specified Style.
      *
      * @param propertyName Specifies the name of the property to which expression is \
added

Modified: trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml
 ===================================================================
--- trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml	2012-01-25 \
                16:01:53 UTC (rev 6728)
+++ trunk/htmlunit/src/main/resources/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml	2012-01-26 \
19:46:12 UTC (rev 6729) @@ -962,6 +962,13 @@
                 descr="MSDN documentation"/>
             <browser name="Internet Explorer"/>
         </function>
+        <function name="removeProperty">
+            <doclink
+                url="https://developer.mozilla.org/en/DOM/CSSStyleDeclaration#Methods"
 +                descr="Gecko DOM reference"/>
+            <browser name="Firefox"/>
+            <browser name="Chrome"/>
+        </function>
         <function name="setAttribute">
             <doclink
                 url="http://msdn.microsoft.com/en-us/library/ms536739.aspx"

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java
 ===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java	2012-01-25 \
                16:01:53 UTC (rev 6728)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java	2012-01-26 \
19:46:12 UTC (rev 6729) @@ -236,6 +236,66 @@
      */
     @Test
     @Browsers(Browser.FF)
+    @Alerts({ "*blue* string", "" })
+    public void removeProperty() throws Exception {
+        final String html = "<html><head><title>First</title><script>\n"
+            + "function doTest() {\n"
+            + "    var oDiv1 = document.getElementById('div1');\n"
+            + "    var value = oDiv1.style.removeProperty('color');\n"
+            + "    alert('*' + value + '* ' + typeof(value));\n"
+            + "    alert(oDiv1.style.cssText);\n"
+            + "}\n"
+            + "</script></head>\n"
+            + "<body onload='doTest()'>\n"
+            + "<div id='div1' style='color: blue'>foo</div></body></html>";
+        loadPageWithAlerts2(html);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Browsers(Browser.FF)
+    @Alerts({ "** string", "blue" })
+    public void removePropertyUnknown() throws Exception {
+        final String html = "<html><head><title>First</title><script>\n"
+            + "function doTest() {\n"
+            + "    var oDiv1 = document.getElementById('div1');\n"
+            + "    var value = oDiv1.style.removeProperty('font-size');\n"
+            + "    alert('*' + value + '* ' + typeof(value));\n"
+            + "    alert(oDiv1.style.getPropertyValue('color'));\n"
+            + "}\n"
+            + "</script></head>\n"
+            + "<body onload='doTest()'>\n"
+            + "<div id='div1' style='color: blue'>foo</div></body></html>";
+        loadPageWithAlerts2(html);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Browsers(Browser.FF)
+    @Alerts({ "** string", "blue" })
+    public void removePropertyUndefined() throws Exception {
+        final String html = "<html><head><title>First</title><script>\n"
+            + "function doTest() {\n"
+            + "    var oDiv1 = document.getElementById('div1');\n"
+            + "    var value = oDiv1.style.removeProperty(undefined);\n"
+            + "    alert('*' + value + '* ' + typeof(value));\n"
+            + "    alert(oDiv1.style.getPropertyValue('color'));\n"
+            + "}\n"
+            + "</script></head>\n"
+            + "<body onload='doTest()'>\n"
+            + "<div id='div1' style='color: blue'>foo</div></body></html>";
+        loadPageWithAlerts2(html);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Browsers(Browser.FF)
     @Alerts({ "30px", "", "30px", "arial", "", "arial" })
     public void getPropertyValue_WithDash() throws Exception {
         final String html =

This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic