Bug 149160 - querySelector() throws exception for -webkit-prefixed pseudo elements
Summary: querySelector() throws exception for -webkit-prefixed pseudo elements
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 9
Hardware: All All
: P2 Normal
Assignee: Anne van Kesteren
URL: http://jsfiddle.net/TheDJ/db27kn7p/
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2015-09-15 05:45 PDT by Derk-Jan Hartman
Modified: 2023-12-20 04:46 PST (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Derk-Jan Hartman 2015-09-15 05:45:44 PDT
Per: http://dev.w3.org/2006/webapi/selectors-api/#interface-definitions

Authors are advised that while the use of pseudo-elements in selectors is permitted, they will not match any elements in the document, and thus would not result in any elements being returned. Therefore, authors are advised to avoid the use of pseudo-elements in selectors that are passed to the methods defined in this specification.

This works as expected (returns null) in Webkit for pseudo elements like ::before and ::after, but all Webkit specific pseudo elements (like -webkit-search-decoration) throws DOM Exception 12

This fails:
document.querySelector( 'input::-webkit-search-decoration' )

See also the console output of this Fiddle: http://jsfiddle.net/TheDJ/db27kn7p/
This will return null in Chrome.
Comment 1 Derk-Jan Hartman 2015-09-15 06:31:52 PDT
Downstream ticket on Wikipedia where we noticed this: https://phabricator.wikimedia.org/T112650

Related ticket in Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1204880
Comment 2 Joseph Pecoraro 2017-01-11 19:36:09 PST
This is still the case.

For example:

    document.querySelector("input::placeholder");

Outputs an Exception in Safari, but returns null in Firefox and Chrome.
Comment 3 Derk-Jan Hartman 2020-10-29 06:09:17 PDT
Still a problem in Safari 14
Comment 4 Derk-Jan Hartman 2021-11-11 11:23:09 PST
Still a problem in 15.1
Comment 5 Ahmad Saleem 2022-08-29 15:24:11 PDT
I am able to reproduce this in Safari Technical Preview 152 as well. It does not show 'null' similar to other browsers (Chrome Canary 107 and Firefox Nightly 106) for third case - console.log( document.querySelector( 'input::-webkit-search-decoration' ) );
Comment 6 Radar WebKit Bug Importer 2022-08-29 15:33:01 PDT
<rdar://problem/99299129>
Comment 7 Derk-Jan Hartman 2023-03-30 07:30:48 PDT
Still present in Safari 16.4
Comment 8 Anne van Kesteren 2023-12-19 09:50:27 PST
Pull request: https://github.com/WebKit/WebKit/pull/22038
Comment 9 EWS 2023-12-20 04:12:31 PST
Committed 272337@main (a23b77e8bca1): <https://commits.webkit.org/272337@main>

Reviewed commits have been landed. Closing PR #22038 and removing active labels.
Comment 10 Anne van Kesteren 2023-12-20 04:46:18 PST
Derk-Jan, sorry voor de vertraging. Als Wikipedia nog andere problemen heeft hoor ik er graag van. Kan niks beloven, maar hopelijk duurt het niet nog een keer acht jaar.