W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2017

Re: [csswg-drafts] [selectors] querySelector() with quote and/or square bracket missing on right

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Fri, 03 Nov 2017 19:56:44 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-341810392-1509739002-sysbot+gh@w3.org>
The example can be simplified to `document.querySelector('[n');`

As expected, the spec says it should fail:

1. [`querySelector`](https://dom.spec.whatwg.org/#dom-parentnode-queryselector) does a [scope-match a selectors string](https://dom.spec.whatwg.org/#dom-parentnode-queryselector).
2. [Scope-match a selectors string](https://dom.spec.whatwg.org/#dom-parentnode-queryselector) [parses a selector](https://drafts.csswg.org/selectors-4/#parse-a-selector).
3. [Parse a selector](https://drafts.csswg.org/selectors-4/#parse-a-selector) parses as a [`<selector-list>`](https://drafts.csswg.org/selectors-4/#typedef-selector-list).
4. A `[` in a [`<selector-list>`](https://drafts.csswg.org/selectors-4/#typedef-selector-list) begins an [`<attribute-selector>`](https://drafts.csswg.org/selectors-4/#typedef-attribute-selector), which must be closed with `]`.
5. Therefore the string does not match the grammar, and [parse a selector](https://drafts.csswg.org/selectors-4/#parse-a-selector) returns failure.
6. Therefore [scope-match a selectors string](https://dom.spec.whatwg.org/#scope-match-a-selectors-string) throws a "SyntaxError" DOMException. 


-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1933#issuecomment-341810392 using your GitHub account
Received on Friday, 3 November 2017 19:56:46 UTC

This archive was generated by hypermail 2.3.1 : Friday, 3 November 2017 19:56:46 UTC