marko-js / language-server

Marko autocomplete, intellisense and editor support.
MIT License
38 stars 8 forks source link

axe-core: current solution for dynamic values produces false positives #202

Closed LuLaValva closed 7 months ago

LuLaValva commented 1 year ago

marko@5.25.11

Details

As of now, extracted HTML replaces all complex attribute expressions with strings which begin with "dynamic". This is insufficient, as it produces false positives in some cases which weren't considered.

Failure Case

<div role='option' aria-selected=isSelected && "true" />

Fix all of the following:     Invalid ARIA attribute value: aria-selected="dynamic0"

Constraints for Solution

  1. Replacing these expressions with some truthy string is necessary, otherwise dynamic required attributes like
    <img src="..." alt=dynamic + string />

    would create an error state.

  2. Non-unique strings like true are also not an option, because then rules like duplicate-id-active and landmark-unique would break in cases like this:
    <div id=first + dynamic />
    <div id=second + dynamic />

Possible solutions

  1. Special case string replacement based on attribute name
    • This can get very messy very quickly, I don't think it's a viable solution
  2. Blacklist rules like duplicate-id-active, and set all dynamic values to a unique string that works everywhere like "true"
    • Untested, I'm not sure if "true" will pass every rule

Right now option 2 seems the most viable, but I would like to give it more thought as well.