Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Test for WCAG technique H56 (dir attribute on an inline element) #72

Closed
kevee opened this issue Dec 14, 2013 · 4 comments
Closed

Test for WCAG technique H56 (dir attribute on an inline element) #72

kevee opened this issue Dec 14, 2013 · 4 comments

Comments

@kevee
Copy link
Collaborator

kevee commented Dec 14, 2013

Create a test for the following WCAG 2.0 technique: http://www.w3.org/TR/WCAG20-TECHS/H56.html
The objective of this technique is to identify changes in the text direction of text that includes nested directional runs by providing the dir attribute on inline elements. A nested directional run is a run of text that includes mixed directional text, for example, a paragraph in English containing a quoted Hebrew sentence which in turn includes an English phrase. Use of the dir attribute on an enclosing span or other inline element may be necessary because the Unicode bidirectional algorithm can produce undesirable results when mixed directional text contains spaces or punctuation.

Test Procdure

  • Examine the text direction of text in the document
  • If the text direction is right-to-left, check that for the ancestor element that has a dir attribute, the attribute has the value "rtl"
  • If the text direction is left-to-right, check that there is no ancestor element with a dir attribute, or that for the ancestor element that has a dir attribute, the attribute has the value "ltr"
@hannolans
Copy link
Contributor

Solution direction:
check1: check the unicode characters, if there are strong RTL and strong LTR characters in a text, DIR should be used in the text (http://www.unicode.org/reports/tr9/#Table_Bidirectional_Character_Types).
check2: If the page has strong RTL characters and no LTR, the document should have RTL explicit

@hannolans
Copy link
Contributor

Found this on http://stackoverflow.com/questions/12006095/javascript-how-to-check-if-character-is-rtl
Not sure if it checks all RTL-scripts

    var rtlChars        = '\u0591-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC',

Edit: Twitter repo is using a slightly different regex to detect rtl hashtags (so notice, without spaces):

twttr.txt.regexen.rtl_chars = /[\u0600-\u06FF]|[\u0750-\u077F]|[\u0590-\u05FF]|[\uFE70-\uFEFF]/mg;

https://github.com/twitter/twitter-text-js/blob/5a888daff71c63567e5d6a408974243b6fcbe550/twitter-text.js

@kevee
Copy link
Collaborator Author

kevee commented Jan 4, 2014

The languageDirAttributeIsUsed test is working well for RTL characters in an LTR page, now I just need to get it to work the other way around.

@kevee
Copy link
Collaborator Author

kevee commented Jan 4, 2014

I've added the following regex to quail for RTL/LTR detection:

  textDirection : {
    rtl : /[\u0600-\u06FF]|[\u0750-\u077F]|[\u0590-\u05FF]|[\uFE70-\uFEFF]/mg,
    ltr : /[\u0041-\u007A]|[\u00C0-\u02AF]|[\u0388-\u058F]/mg
  },

The test goes through elements and can switch back and forth between RTL/LTR contexts and then determine if there is a mix in any text element that is not captured in an element with a dir attribute.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants