Skip to content

SyntaxError parsing unknown pseudo-class selector :-moz-read-only #150

@alexjamesmacpherson

Description

@alexjamesmacpherson

My team has observed NWSAPI yielding a syntax error when parsing the :-moz-read-only pseudo-class selector. From debug inspection, the full selector_string to be parsed is :scope input:-moz-read-only, with the :-moz-read-only then parsed from this string.

This error is occurring during a React Testing Library test for a React component which renders the MaterialUI Autocomplete component, which it seems implements this selector somewhere in its styling.

To be clear, we are not attempting to select an element using this selector, but the failure to parse the selector at all prevents us from using other selectors.

From testing, this issue did not exist in NWSAPI v2.2.7 and below, and began to occur from v2.2.8 onwards.

It is difficult to workaround this issue in our test code, as the failure to parse the unknown selector limits the selection methods we're able to use in our tests. We are also unable to remove the selector from the offending component as it is implemented by a 3rd party.

From limited testing, NWSAPI can be trivially modified to include -moz-read-only in the pseudo_nop regex def (see #151), which facilitates successfully parsing and ignoring the selector - but I wonder whether it would be safer in general to simply ignore unknown selectors rather than throwing, as I imagine there may be other -moz-* selectors which exhibit the same issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions