WICG / spatial-navigation

Directional focus navigation with arrow keys
https://drafts.csswg.org/css-nav-1/
Other
216 stars 38 forks source link

Using Spatial Navigation Action API #185

Open jervisfm opened 5 years ago

jervisfm commented 5 years ago

Hi,

In the spatial navigation action polyfill demo (https://wicg.github.io/spatial-navigation/demo/sample/api_spatial_navigation_action.html), the demonstrated usage is explicitly setting the --spatial-navigation-action property directly on the element. Code link: https://github.com/WICG/spatial-navigation/blob/226ebb0a6124f34e708a9fc2c33c4d42a4449645/demo/sample/api_spatial_navigation_action.html#L87

The current released implementation uses element.style.getPropertyValue to read the custom property value. Link: https://github.com/WICG/spatial-navigation/blob/226ebb0a6124f34e708a9fc2c33c4d42a4449645/polyfill/spatial-navigation-polyfill.js#L476

The result of this is that styles that are applied by a CSS stylesheet do not seem to be picked up and so the automatic "focus" navigation is not enabled for them.

Just wanted to ask if the intended usage for this API is directly setting the style property inline on the applicable elements and not via a CSS stylesheet?

One can imagine that using getComputedStyle as is to get the overall computed styles might be expensive and thus it's not done here.

Thanks.