[HtmlUnit] SVN: [14744] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14744] trunk/htmlunit/src

HtmlUnit - Dev mailing list
Revision: 14744
          http://sourceforge.net/p/htmlunit/code/14744
Author:   rbri
Date:     2017-07-30 14:20:35 +0000 (Sun, 30 Jul 2017)
Log Message:
-----------
more fixes

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenListTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-07-30 13:24:03 UTC (rev 14743)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-07-30 14:20:35 UTC (rev 14744)
@@ -852,8 +852,12 @@
     @BrowserFeature({CHROME, IE})
     JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_EDIT,
 
+    /** DOMTokenList removed all whitespace chars during add. */
+    @BrowserFeature(CHROME)
+    JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_ADD,
+
     /** DOMTokenList removed all whitespace chars during remove. */
-    @BrowserFeature(CHROME)
+    @BrowserFeature({CHROME, FF52})
     JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE,
 
     /** Javascript property function {@code delete} throws an exception if the given count is negative. */

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java 2017-07-30 13:24:03 UTC (rev 14743)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java 2017-07-30 14:20:35 UTC (rev 14744)
@@ -18,6 +18,7 @@
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_ENHANCED_WHITESPACE_CHARS;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_GET_NULL_IF_OUTSIDE;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_LENGTH_IGNORES_DUPLICATES;
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_ADD;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_EDIT;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE;
 import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
@@ -129,15 +130,20 @@
         }
 
         String value = getDefaultValue(null);
+        boolean changed = false;
         if (position(value, token) < 0) {
             if (value.length() != 0 && !isWhitespache(value.charAt(value.length() - 1))) {
                 value = value + " ";
             }
             value = value + token;
-            updateAttribute(value);
+            changed = true;
         }
-        else if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE)) {
+        else if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_ADD)) {
             value = String.join(" ", StringUtils.split(value, whitespaceChars()));
+            changed = true;
+        }
+
+        if (changed) {
             updateAttribute(value);
         }
     }
@@ -156,6 +162,7 @@
         }
 
         String value = getDefaultValue(null);
+        boolean changed = false;
         int pos = position(value, token);
         while (pos != -1) {
             int from = pos;
@@ -176,16 +183,20 @@
                 }
             }
             result.append(value, to, value.length());
-
             value = result.toString();
+            changed = true;
 
-            if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE)) {
-                value = String.join(" ", StringUtils.split(value, whitespaceChars()));
-            }
-            updateAttribute(value);
-
             pos = position(value, token);
         }
+
+        if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE)) {
+            value = String.join(" ", StringUtils.split(value, whitespaceChars()));
+            changed = true;
+        }
+
+        if (changed) {
+            updateAttribute(value);
+        }
     }
 
     /**

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenListTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenListTest.java 2017-07-30 13:24:03 UTC (rev 14743)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenListTest.java 2017-07-30 14:20:35 UTC (rev 14744)
@@ -14,15 +14,11 @@
  */
 package com.gargoylesoftware.htmlunit.javascript.host.dom;
 
-import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.CHROME;
-import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF52;
-
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
-import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented;
 import com.gargoylesoftware.htmlunit.WebDriverTestCase;
 
 /**
@@ -694,7 +690,6 @@
     @Alerts(DEFAULT = {" \t \n  ", "0", "0", " \t \n  "},
             CHROME = {" \t \n  ", "0", "0", ""},
             FF52 = {" \t \n  ", "0", "0", ""})
-    @NotYetImplemented({CHROME, FF52})
     public void removeFromWhitespace() throws Exception {
         remove(" \t \r  ", "a");
     }
@@ -753,7 +748,6 @@
     @Test
     @Alerts(DEFAULT = {"a \t c \n d  e", "4", "3", "a d e"},
             FF45 = {"a \t c \n d  e", "4", "3", "a d  e"})
-    @NotYetImplemented(FF52)
     public void removeWhitespace() throws Exception {
         remove("a \t c \n d  e", "c");
     }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop