Handle aria-current=false as False instead of True - #7901
Conversation
LeonarddeR
left a comment
There was a problem hiding this comment.
I'm afraid this pr is not complete yet, as it only covers virtual buffers, neither Edge browse mode nor the object level. It also seems that the doc string of the iscurrent object property is in error, as it says that a value of "true" should return the True boolean value, but I belief it never does and always returns "true" as a string.
|
For the sake of reference |
|
The first attempt at this was incomplete. Now this PR should cover all cases and the docstring for NVDAObject._get_isCurrent has been fixed as suggested by @LeonarddeR. |
LeonarddeR
left a comment
There was a problem hiding this comment.
This looks good, though I'm still a bit worried about the isCurrent property returning either a boolean or a string. Personally I'd make it return None instead of False, but that's unrelated. A real issue though seems to be the regex, even though that's not a regression in your code, it might be good to address that here.
| @@ -458,7 +458,7 @@ def _get_ariaProperties(self): | |||
| # in a list of strings like "something=true;current=date;". We want to capture one group, after the '=' | |||
| # character and before the ';' character. | |||
| # This could be one of: True, "page", "step", "location", "date", "time" | |||
There was a problem hiding this comment.
Could you update this comment to add "false" as a valid value?
There was a problem hiding this comment.
I also double checked in edge. True should be listed as "true"
| # character and before the ';' character. | ||
| # This could be one of: True, "page", "step", "location", "date", "time" | ||
| RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(\w+);") | ||
| RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(?!false)(\w+);") |
There was a problem hiding this comment.
This regex seems a bit broken:
- RE_ARIA_CURRENT_PROP_VALUE.match("current=true;dummy=test;") properly matches
- RE_ARIA_CURRENT_PROP_VALUE.match("var=val;current=true;dummy=test;") does not match
May be we need a unit test for this. cc @feerrenrut
| @@ -458,7 +458,7 @@ def _get_ariaProperties(self): | |||
| # in a list of strings like "something=true;current=date;". We want to capture one group, after the '=' | |||
| # character and before the ';' character. | |||
| # This could be one of: True, "page", "step", "location", "date", "time" | |||
There was a problem hiding this comment.
I also double checked in edge. True should be listed as "true"
| it will return one of the following values: True, "page", "step", "location", "date", "time" | ||
| it will return one of the following values: "true", "page", "step", "location", "date", "time" | ||
| """ | ||
| return False |
There was a problem hiding this comment.
Given this returns boolean False I think it would be best if we converted "true" to boolean True. Or perhaps better would be to return one off: None, 'true', 'page', etc
* isCurrent defaults to None instead of False, so now it returns either
None or one of the allowed strings ("true", "page", etc)
* Use the search method on the regular expression to match the
aria-current attribute in Edge, so it is also found if it's not the
first attribute in the string. Also, document that false is a valid
value.
| # This could be one of: True, "page", "step", "location", "date", "time" | ||
| RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(\w+);") | ||
| # This could be one of: "false", "true", "page", "step", "location", "date", "time" | ||
| # "false" is ignored, so it falls back to the default implementation, which is false |
There was a problem hiding this comment.
Shouldn't the latter false be none?
There was a problem hiding this comment.
This is a comment about the regular expression, which is outside of the isCurrent method and the false here refers to the false as value of the aria-current attribute. That's also the reason why it is written without a capital F. So, I think this comment is correct.
There was a problem hiding this comment.
The comment on Line 461 confuses me a little too. It sounds like it is talking about the default implementation of the isCurrent method, perhaps you could clear this up? I think it would be clearer to say something like:
# "false" is ignored by the regEx and will not produce a match
There was a problem hiding this comment.
Thanks for the suggestion, I just commited the improved comment
|
Looks good. |
Link to issue number:
Issue #7892
Summary of the issue:
Aria-current="false' is one of the allowed values according to the ARIA 1.1 spec and should be handled as False. Currently, it is handled as True.
Description of how this pull request fixes the issue:
Don't include the aria-current attribute if its' value is false or None. Previously it was only None.
Testing performed:
Tested in Firefox Nightly, Chrome, Edge and Internet Explorer in a virtual buffer as well as in focus mode.
Known issues with pull request:
None.
Change log entry: