]> Kevux Git Server - quail-php/commitdiff
Apply bugfix patches from issues 29, 30, 31, 32, 33, 34, and 35
authorKevin Day <thekevinday@gmail.com>
Thu, 23 May 2019 21:48:11 +0000 (16:48 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 23 May 2019 21:48:11 +0000 (16:48 -0500)
see: https://code.google.com/archive/p/quail-lib/issues/29
see: https://code.google.com/archive/p/quail-lib/issues/30
see: https://code.google.com/archive/p/quail-lib/issues/31
see: https://code.google.com/archive/p/quail-lib/issues/32
see: https://code.google.com/archive/p/quail-lib/issues/33
see: https://code.google.com/archive/p/quail-lib/issues/34
see: https://code.google.com/archive/p/quail-lib/issues/35

quail/common/accessibility_tests.php
quail/common/css.php
quail/common/test.php
quail/guidelines/translations/en.txt

index 04b9b1936cc9d268f28427a6ec313b2fb7fb6aec..8efe5b3ee2cc56a9957de428b0691fb6167dceb7 100755 (executable)
@@ -1138,7 +1138,7 @@ class cssTextHasContrast extends quailColorTest {
                                $background = (isset($style['background-color']))
                                                           ? $style['background-color']
                                                           : $style['background'];
-                               if(!$background || $this->options['css_only_use_default']) {
+                               if(!$background || (isset($this->options['css_only_use_default']) && $this->options['css_only_use_default'])) {
                                        $background = $this->default_background;
                                }
                                $luminosity = $this->getLuminosity(
@@ -2238,7 +2238,7 @@ class formWithRequiredLabel extends quailTest {
                        }
                        if($k) {
                                foreach($this->suspect_styles as $style) {
-                                       if($styles[$k][$style] != $styles[($k - 1)][$style]) {
+                                       if(isset($styles[$k][$style]) && $styles[$k][$style] != $styles[($k - 1)][$style]) {
                                                $form = $this->getElementAncestor($label, 'form');
                                                if($form) {
                                                        $this->addReport($form);
@@ -4543,8 +4543,8 @@ class pNotUsedAsHeader extends quailTest {
        */
        function check() {
                foreach($this->getAllElements('p') as $p) {
-                       if(($p->nodeValue == $p->firstChild->nodeValue) &&
-                               is_object($p->firstChild) &&
+                       if (is_object($p->firstChild) &&
+                               ($p->nodeValue == $p->firstChild->nodeValue) &&
                                property_exists($p->firstChild, 'tagName') && 
                                in_array($p->firstChild->tagName, $this->head_tags)) {
                                        $this->addReport($p);
@@ -4552,7 +4552,7 @@ class pNotUsedAsHeader extends quailTest {
                        }
                        else {
                                $style = $this->css->getStyle($p);
-                               if($style['font-weight'] == 'bold') {
+                               if(isset($style['font-weight']) && $style['font-weight'] == 'bold') {
                                        $this->addReport($p);
                                }
                        }
@@ -5266,6 +5266,18 @@ class tableHeaderLabelMustBeTerse extends quailTableTest {
                                                }
                                        }
                                }
+                               else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+                                       foreach ($child->childNodes as $tbody_child){
+                                               if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+                                                       foreach($tbody_child->childNodes as $td) {
+                                                               if($this->propertyIsEqual($td, 'tagName', 'th')) {
+                                                                       if(strlen($td->getAttribute('abbr')) > 20)
+                                                                               $this->addReport($td);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
                        }
                        
                }
@@ -5388,6 +5400,15 @@ class tableLayoutHasNoSummary extends quailTableTest {
                                                        $this->addReport($table);
                                                $first_row = false;
                                        }
+                                       else if($this->propertyIsEqual($child, 'tagName', 'tbody') && $first_row) {
+                                               foreach($child->childNodes as $tbody_child) {
+                                                       if($this->propertyIsEqual($tbody_child, 'tagName', 'tr') && $first_row) {
+                                                               if(!$this->elementHasChild($tbody_child, 'th'))
+                                                                       $this->addReport($table);
+                                                               $first_row = false;
+                                                       }
+                                               }
+                                       }
                                }
                        }
                }
@@ -5639,11 +5660,28 @@ class tableWithBothHeadersUseScope extends quailTest {
                                        }
                                        else {
                                                foreach($child->childNodes as $td) {
+                                                       if (!property_exists($td, 'tagName')) continue;
                                                        if($td->tagName == 'th' && !$td->hasAttribute('scope'))
                                                                $fail = true;
                                                }
                                        }
                                }
+                               else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+                                       foreach($child->childNodes as $tbody_child) {
+                                               if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+                                                       if($this->propertyIsEqual($tbody_child->firstChild, 'tagName', 'td')) {
+                                                               if(!$tbody_child->firstChild->hasAttribute('scope'))
+                                                                       $fail = true;
+                                                       }
+                                                               foreach($tbody_child->childNodes as $td) {
+                                                                       if(property_exists($td, 'tagName')){
+                                                                               if($td->tagName == 'th' && !$td->hasAttribute('scope'))
+                                                                                       $fail = true;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
                        }
                        if($fail)
                                $this->addReport($table);
@@ -5681,7 +5719,20 @@ class tableWithMoreHeadersUseID extends quailTableTest {
                                                                if($row > 1) 
                                                                        $multi_headers = true;  
                                                        }
-                                                               
+                                               }
+                                       }
+                                       else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+                                               foreach($child->childNodes as $tbody_child) {
+                                                       if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+                                                               $row ++;
+                                                               foreach($tbody_child->childNodes as $cell) {
+                                                                       if($this->propertyIsEqual($cell, 'tagName', 'th')) {
+                                                                               $th[] = $cell;
+                                                                               if($row > 1) 
+                                                                                       $multi_headers = true;  
+                                                                       }
+                                                               }
+                                                       }
                                                }
                                        }
                                }
@@ -6039,4 +6090,4 @@ class textIsNotSmall extends quailTest {
 
 }
 
-/*@}*/
\ No newline at end of file
+/*@}*/
index f286195d06e9c9e7ff5df8857097be00c34d75e5..58770dd569aabb3386932e3e0a150f230404a837 100644 (file)
@@ -123,7 +123,7 @@ class quailCSS {
                foreach($this->css as $selector => $style) {
                        $xpath = new DOMXPath($this->dom);
                        $entries = @$xpath->query($this->getXpath($selector));
-                       if($entries->length) {
+                       if(is_object($entries) && property_exists($entries, 'length') && $entries->length) {
                                foreach($entries as $e) {
                                        if(!$e->hasAttribute('quail_style_index')) {
                                                $e->setAttribute('quail_style_index', $this->next_index);
@@ -149,10 +149,16 @@ class quailCSS {
        */
        private function addCSSToElement($element, $style, $specificity) {
                $index_id = $element->getAttribute('quail_style_index');
+               if (!isset($this->style_index[$index_id])){
+                       $this->style_index[$index_id] = array();
+               }
+
                foreach($style as $name => $value) {
-                       if(!$this->style_index[$index_id][$name] ||
-                           $this->style_index[$index_id][$name]['specificity'] < $specificity
-                           || strpos($value, '!important') !== false) 
+                       if(!isset($this->style_index[$index_id][$name]) ||
+                         !$this->style_index[$index_id][$name] ||
+                         (isset($this->style_index[$index_id][$name]['specificity']) &&
+                         $this->style_index[$index_id][$name]['specificity'] < $specificity) ||
+                         strpos($value, '!important') !== false)
                        {
                                $this->style_index[$index_id][$name] = array(
                                        'value' => str_replace('!important', '', trim(strtolower($value))),
@@ -264,6 +270,7 @@ class quailCSS {
                        $inline_styles = explode(';', $element->getAttribute('style'));
                        foreach($inline_styles as $inline_style) {
                                $s = explode(':', $inline_style);
+                               if (!isset($s[1])) continue;
                                $style[$s[0]] = trim(strtolower($s[1]));
                        }
                }
index 99a6affa9d5a5c5fb110943cff79b5cdcb9826f8..7157a020ff82043355aa07cf5a1ce1470756d77f 100644 (file)
@@ -513,10 +513,22 @@ class quailTableTest extends quailTest {
                if($table->tagName != 'table') 
                        return false;
                foreach($table->childNodes as $child) {
-                       if(property_exists($child, 'tagName') && $child->tagName == 'tr') {
-                               foreach($child->childNodes as $row_child) {
-                                       if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
-                                               return true;
+                       if(property_exists($child, 'tagName')){
+                               if ($child->tagName == 'tr') {
+                                       foreach($child->childNodes as $row_child) {
+                                               if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
+                                                       return true;
+                                       }
+                               }
+                               else if ($child->tagName == 'tbody') {
+                                       foreach($child->childNodes as $tbody_child) {
+                                               if (property_exists($tbody_child, 'tagName') && $tbody_child->tagName == 'tr') {
+                                                       foreach($tbody_child->childNodes as $row_child) {
+                                                               if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
+                                                                       return true;
+                                                       }
+                                               }
+                                       }
                                }
                        }
                        if(property_exists($child, 'tagName') && $child->tagName == 'thead')
@@ -987,4 +999,4 @@ class bodyColorContrast extends quailColorTest {
                        if( $this->getLuminosity($body->getAttribute($this->foreground), $body->getAttribute($this->background)) < 5)
                                $this->addReport(null, null, false);
        }
-}
\ No newline at end of file
+}
index 9889ee91e7f600fcd2d6bf2582c63e1fcb53e829..874368a0d58a2c3efad636586a3dc712d28373d5 100644 (file)
@@ -1,6 +1,6 @@
 "imgHasAlt","Image elements must have an ""alt"" attribute","<p>All <code>img</code> elements must have an alt attribute</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
 "imgAltIsDifferent","Image ""alt"" attributes should not be the same as the filename","<p>All <code>img</code> elements should have an ""alt"" attribute that is not just the name of the file, unless the filename communicates everything about the file.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt=""dog.jpg""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
-"imgAltIsTooLong","Image Alt text is short","<p>All ""alt"" attributes for <code>img</code> elements should be clear and concise. ""Alt"" attributes over 100 characters long should be reviewed to see if they are too long.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of my very, very, very special dog whom I love so much. He is a very good dog, a loving dog, and my constant companion these many years. Yes, all agree, my dog is a good dog.""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
+"imgAltIsTooLong","Image Alt text is too long","<p>All ""alt"" attributes for <code>img</code> elements should be clear and concise. ""Alt"" attributes over 100 characters long should be reviewed to see if they are too long.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of my very, very, very special dog whom I love so much. He is a very good dog, a loving dog, and my constant companion these many years. Yes, all agree, my dog is a good dog.""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
 "imgNonDecorativeHasAlt","Any non-decorative images should have a non-empty ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an empty ""alt"" attribute.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt=""""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","2"
 "imgImportantNoSpacerAlt","Images that are important should not have a purely white-space ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an ""alt"" attribute that consists solely of white space (i.e. a space, or a new line).</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt="" ""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
 "imgAltNotPlaceHolder","Images should not have a simple placeholder text as an ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an ""alt"" attribute that consists solely of placeholders. Placeholders include:</p><ul><li>nbsp</li><li>&amp;nbsp;</li><li>spacer</li><li>image</li><li>img</li><li>photo</li></ul><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=""dog.jpg"" alt=""image""&gt;</code></p><h5>Right</h5><p><code>&lt;img src=""dog.jpg"" alt=""A photograph of a dog""&gt;</code></p>","1"
@@ -31,7 +31,7 @@
 "frameTitlesDescribeFunction","All ""frame"" elemetns should have a ""title"" attribute that describes the purpose of the frame","<p>Each <code>frame</code> elements should have a ""title"" attribute which describes the purpose or function of the frame.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;frame src=""navigation.html""&gt;&lt;/frame&gt;</code></p><h5>Right</h5><p><code>&lt;frame src=""navigation.html"" title=""The site navigation""&gt;&lt;/frame&gt;</code></p>","3"
 "frameSrcIsAccessible","The source for each frame is accessible content.","<p>Each frame should contain accessible content, and contain content accessible to screen readers, like HTML as opposed to an image.</p>","3"
 "frameRelationshipsMustBeDescribed","Complex framesets should contain a ""longdesc"" attribute","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;frameset cols=""25%,50%,25%""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;&lt;/frameset&gt;</code></p><h5>Right</h5><p><code>&lt;frameset cols=""25%,50%,25%"" longdesc=""description.html""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;&lt;/frameset&gt;</code></p>","2"
-"framesetMustHaveNoFramesSection","All framesets should contain a noframes section","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;frameset cols=""25%,50%,25%""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;&lt;/frameset&gt;</code></p><h5>Right</h5><p><code>&lt;frameset cols=""25%,50%,25%"" longdesc=""description.html""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;  &lt;noframes&gt;       &lt;body&gt;            This is more information for users without frames. It should contain links to all the other frames.     &lt;/body&gt;  &lt;/noframes&gt;&lt;/frameset&gt;</code></p>","1"
+"framesetMustHaveNoFramesSection","All framesets should contain a noframes section","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;frameset cols=""25%,50%,25%""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;&lt;/frameset&gt;</code></p><h5>Right</h5><p><code>&lt;frameset cols=""25%,50%,25%"" longdesc=""description.html""&gt;  &lt;frame src=""frame_1.htm"" /&gt;  &lt;frame src=""frame_2.htm"" /&gt;  &lt;frame src=""frame_3.htm"" /&gt;  &lt;noframes&gt;    &lt;body&gt;      This is more information for users without frames. It should contain links to all the other frames.   &lt;/body&gt;  &lt;/noframes&gt;&lt;/frameset&gt;</code></p>","1"
 "noframesSectionMustHaveTextEquivalent","All ""noframes"" elements should contain the text content from all frames","<p>The <code>noframes</code> content should either replicate or link to the content visible within the frames.</p>","2"
 "headerH1","The header following an h1 is h1 or h2","<p>The header following an <code>h1</code> element should either be an <code>h2</code> or another <code>h1</code>.</p><p>Users of screen readers often use headers to make sense of the structure of the document, and having headers in the right order can be very helpful. It also helps the document itself to be consistently structured.</p>
 ","3"
 ","2"
 "linkUsedToDescribeNavigation","Document uses link element to describe navigation if it is within a collection.","The link element can provide metadata about the position of an HTML page within a set of Web units or can assist in locating content with a set of Web units.","1"
 "linkUsedForAlternateContent","Use a ""link"" element for alternate content","<p>Documents which contain things like videos, sound, or other forms of media that are not accessible, should provide a <code>link</code> element with a ""rel"" attribute of ""alternate"" in the document header.</p><h4>Example</h4><p><code>&lt;head&gt;&lt;link rel=""alternate"" href=""transcription.html""/&gt;&lt;/head&gt;</code></p>","3"
-"tableUsesCaption","Data tables should contain a ""caption"" element if not described elsewhere","<p>Unless otherwise described in the document, tables should contain <code>caption</code> elements to describe the purpose of the table.</p><h4>Example</h4><table><caption>A short description of this table</caption></table>","1"
+"tableUsesCaption","Data tables should contain a ""caption"" element if not described elsewhere","<p>Unless otherwise described in the document, tables should contain <code>caption</code> elements to describe the purpose of the table.</p><h4>Example</h4><p><code>&lt;table&gt;&lt;caption&gt;A short description of this table&lt;/caption&gt;&lt;/table&gt;</code></p>","1"
 "tableUsesAbbreviationForHeader","Table headers over 20 characters should provide an ""abbr"" attribute","<p>For long table headers, use an ""abbr"" attribute that is less than short (less than 20 characters long).</p><h4>Examples</h4><h5>Wrong</h5><p><code>&lt;th&gt;The total number of people who liked chocolate&lt;/th&gt;</code></p><h5>Right</h5><p><code>&lt;th abbr=""Like Chocolate""&gt;The total number of people who liked chocolate&lt;/th&gt;</code></p>","3"
 "tableHeaderLabelMustBeTerse","Table header lables must be terse","<p>The ""abbr"" attribute for table headers must be terse (less than 20 characters long).</p>","2"
 "preShouldNotBeUsedForTabularLayout","""Pre"" elements should not be used for tabular data","<p>If a <code>pre</code> element is used for tabular data, change the data to use a well-formed table.</p>
 "labelsAreAssignedToAnInput","All labels should be associated with an input","<p>All <code>label</code> elements should be assigned to an input item, and should have a <em>for</em> attribute which equals the <em>id</em> attribute of a form element.</p>","1"
 "imgAltTextNotRedundant","Unless the image files are the same, no image should contain redundant alt text","<p>Every distinct image on a page should have it's own <em>alt</em> text which is different than all the others on the page to avoid redundancy and confusion.</p><h4>Example</h4><h5>Wrong</h5><p><code>&lt;img src=&quot;rex.jpg&quot; alt=&quot;this is an image of rex&quot;&gt;&lt;img src=&quot;me.jpg&quot; alt=&quot;this is an image of rex&quot;&gt;</code></p><h5>Right</h5><p><code>&lt;img src=&quot;rex.jpg&quot; alt=&quot;this is an image of rex&quot;&gt;&lt;img src=&quot;me.jpg&quot; alt=&quot;a photo of myself&quot;&gt;</code></p>","1"
 "selectJumpMenus","Select jump menus should jump on button press, not on state change","<p>If you wish to use a 'Jump' menu with a select item that then redirects users to another page, the jump should occur on the user pressing a button, rather than on the change event of that select eleemnt.</p>","2"
-"textIsNotSmall","The text size is not less than 9 pixels high","<p>To help users with difficulty reading small text, ensure text size is no less than 9 pixels high.</p>","2"
\ No newline at end of file
+"textIsNotSmall","The text size is not less than 9 pixels high","<p>To help users with difficulty reading small text, ensure text size is no less than 9 pixels high.</p>","2"