From: <rb...@us...> - 2017-08-30 18:41:06
|
Revision: 14808 http://sourceforge.net/p/htmlunit/code/14808 Author: rbri Date: 2017-08-30 18:41:04 +0000 (Wed, 30 Aug 2017) Log Message: ----------- take care of important also Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 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 2017-08-30 17:35:49 UTC (rev 14807) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2017-08-30 18:41:04 UTC (rev 14808) @@ -414,13 +414,9 @@ value = element2.getValue(); } else { - final int comp = element1.getSpecificity().compareTo(element2.getSpecificity()); - if (comp > 0) { + if (element1.compareTo(element2) > 0) { return element1.getValue(); } - if (comp == 0 && element1.getIndex() > element2.getIndex()) { - return element1.getValue(); - } value = element2.getValue(); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-30 17:35:49 UTC (rev 14807) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-30 18:41:04 UTC (rev 14808) @@ -2151,6 +2151,32 @@ * @throws Exception if an error occurs */ @Test + @Alerts("48") + public void combineStylesImportant() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + "<style type='text/css'>\n" + + " div { margin: 10px 20px 30px 40px !important; }\n" + + "</style>\n" + + "<script>\n" + + " function test() {\n" + + " var div = document.getElementById('div1');\n" + + " var left = div.style.marginLeft;\n" // force the resolution + + " alert(div.offsetLeft);\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <div id='div1' style='margin-left: 123px'></div>\n" + + "</body></html>\n"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts("23") public void combineStylesBrowserDefaults() throws Exception { final String html = "<html>\n" |