Bug 178392 - DOM Selector parsing doesn't support selectors without ending tokens
Summary: DOM Selector parsing doesn't support selectors without ending tokens
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 11
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-17 09:30 PDT by Jordan Foreman
Modified: 2024-03-15 05:54 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jordan Foreman 2017-10-17 09:30:05 PDT
This bug was originally uncovered through jQuery's selector, but the behavior is consistent with document.querySelector (the underlying selector parsing is the same).

Per the CSS Working Group's spec - https://drafts.csswg.org/css-syntax/#rule-defs:

> When defining a function or a block, the ending token must be specified in the grammar, but if it’s not present in the eventual token stream, it still matches.

For example, the following will throw an exception in Safari: 

```
document.querySelector('[data-my-target="someId"');
```

Note the lack of a closing brace (]) in the selector. 

While I have my own opinions on this matter, it is inconsistent with other major browsers (Chrome and Firefox), and seems to run contrary to the working group's specification.

Note: this may be an issue specifically with Safari and not Webkit. I don't have access to Webkit builds on my work computer, otherwise I'd validate that
Comment 1 Anne van Kesteren 2024-03-15 05:54:35 PDT
Thanks for the report! It seems this got fixed at some point.