Search code examples
javascriptdomselectors-api

querySelector is not in the living standard


Some features of the document.querySelector are not supported. I am worried that future changes made to the standard will bring change that might break code. I'm asking, as I discovered, KeyboardEvent.keyCode is likely to be removed and recommend to be replaced by KeyboardEvent.code this is an understandable change given depending on the keyboard the behavior changes but it doesn't change the fact that removing it breaks legacy sites and appilcations.

What is the fate regarding querySelector and the living standard; it confuses me.

I'm getting my question from second hand research from mozilla's documentation on the matter. Know I might understand better the intent if I was better in tune with W3C's precedent but I have trouble finding and reading W3C's intentions. https://dom.spec.watwag.org describes it and only mentions an intention to not add namespaces. I'm slightly confused on the matter and was hoping someone would know more then I.


Solution

  • I'm getting my question from second hand research from mozilla's documentation on the matter. Know I might understand better the intent if I was better in tune with W3C's precedent but I have trouble finding and reading W3C's intentions.

    The obsolete selectors-api2 spec says that the Selectors API definitions have been merged into the DOM spec. Being the W3C, this is referring to their own DOM spec; the living DOM spec is dom.spec.whatwg.org (unlike the WHATWG, the W3C generally doesn't call their specs living specs because every TR is versioned and each version goes through its own standardization process). For some reason that MDN article doesn't contain a link to either DOM spec despite now correctly labeling the W3C Selectors API specs obsolete.

    So no, querySelector() isn't going away, hasn't been deprecated. Nothing to worry about.

    ... describes it and only mentions an intention to not add namespaces.

    That's just referring to the Selectors API not providing support for namespaced type and attribute selectors since those require a @namespace CSS at-rule, which cannot appear in or around a selector, to work.