Bug 178392

Summary: DOM Selector parsing doesn't support selectors without ending tokens
Product: WebKit Reporter: Jordan Foreman <thejordanforeman>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: annevk, cdumez, hyatt, koivisto, simon.fraser
Priority: P2    
Version: Safari 11   
Hardware: All   
OS: All   

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.