[whatwg/dom] Inconsistency in execution of unclosed attribute selector for querySelector (#549)

(Note: I hope this is the correct repository to file a bug. If not, please move this issue to the correct place)

In https://github.com/PolymerElements/iron-form/pull/222#discussion_r157619096 we discovered an inconsistency in parsing and execution of invalid `querySelector` with an unclosed attribute selector. In our [Travis build](https://travis-ci.org/PolymerElements/iron-form/builds/317379019#L2478-L2540), all OS X Safari tests failed with the error `SyntaxError: DOM Exception 12: An invalid or illegal string was specified.`.

However, all other browsers happily accept the unclosed attribute selector and do not throw an error. Based on this finding, I browsed [the DOM standard](https://dom.spec.whatwg.org/#dom-element-matches) which pointed to [this section in Selectors Level 4](https://www.w3.org/TR/selectors4/#attribute-representation). In this case, the DOM specification states that a failure in parsing of the selector must throw a `SyntaxError`. However, based on [the specification of invalid CSS Selectors](https://www.w3.org/TR/selectors4/#invalid), the notion of invalid denotes an unexpected token or namespace prefix. It is unclear what an unclosed selector denotes, which also means that (imo) the behavior of unclosed selectors is undefined.

Based on the undefinedness, it appears that browsers interpret the "failure of parsing" in multiple ways and depending on this condition either throw or don't throw a `SyntaxError` per the DOM standard. 

Therefore I would like to know what the specced behavior of "failure of parsing" is or should be. In the case that it is already specced, maybe a `web-platform-test` can be added to verify this behavior to reduce the inconsistency?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/549

Received on Tuesday, 19 December 2017 10:11:34 UTC