mathbox icon indicating copy to clipboard operation
mathbox copied to clipboard

Internal functions occasionally make invalid css queries

Open sritchie opened this issue 3 years ago • 0 comments

Some internal mathbox functions query Mathbox's DOM using invalid CSS selector queries.

For example:

  1. Edit Mathbox source at https://gitgud.io/unconed/mathbox/-/blob/master/src/model/model.js#L322 to console.log its first argument, a css selector query.
  2. Rebuild, and load examples/test/rtt.html

You will find that one of the queries logged to console is the string

vec4 getSample(vec2 xy);
vec4 getFramesSample(vec2 xy) { return getSample(xy); }

which is clearly not a valid css selector query.

Do we care?

Probably not right now.

I suspect Mathbox has always made these invalid queries, and the css-selection library cssauron tolerated them fine: it would just return false since no elements matched these invalid selectors. These invalid queries seem not to be causing any bugs.

I discovered this while working on replacing cssauron with css-select. The new library, css-select, is a bit stricter in that it throws errors when passed invalid css selectors. This error-throwing behavior seems desirable to me. (For one thing, it's consistent with the browser-native Element.querySelector API.)

Embracing the new error-throwing behavior probably requires preventing Mathbox internal functions from making these invalid CSS queries.

sritchie avatar Mar 31 '22 15:03 sritchie