Skip to content

Conversation

@bramd
Copy link
Contributor

@bramd bramd commented Jan 6, 2018

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:

Copy link
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@feerrenrut
Copy link
Contributor

For the sake of reference aria-current support was implemented in PR #6860

@bramd
Copy link
Contributor Author

bramd commented Jan 8, 2018

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.

Copy link
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

# RegEx to get the value for the aria-current property. This will be looking for a the value of 'current'
# 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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update this comment to add "false" as a valid value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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+);")
Copy link
Collaborator

@LeonarddeR LeonarddeR Jan 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex seems a bit broken:

  1. RE_ARIA_CURRENT_PROP_VALUE.match("current=true;dummy=test;") properly matches
  2. 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

# RegEx to get the value for the aria-current property. This will be looking for a the value of 'current'
# 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

bramd added 2 commits January 13, 2018 22:24
 * 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the latter false be none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I just commited the improved comment

@LeonarddeR
Copy link
Collaborator

Looks good.

feerrenrut added a commit that referenced this pull request Jan 29, 2018
Merge remote-tracking branch 'origin/pr/7901' into next
@michaelDCurran michaelDCurran merged commit d338d58 into nvaccess:master Mar 6, 2018
@nvaccessAuto nvaccessAuto added this to the 2018.1 milestone Mar 6, 2018
@michaelDCurran michaelDCurran modified the milestones: 2018.1, 2018.2 Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants