Search code examples
javascriptselectorselectors-api

querySelector method obsoleted?


I'm currently learning the querySelector method and was surprised to find that it was classified as obsolete

enter image description here

Here is the link to the screenshot

Is querySelector method really has been obsoleted? If yes, what is the reason? And what method should be used instead?


Solution

  • The method querySelector is not obsolete. Obsolete methods are generally highlighted on MDN with a warning like this:

    You can see an example here: https://developer.mozilla.org/en-US/docs/Web/API/Document/registerElement


    It looks like the list of specifications hasn't been updated on that page. However if you look at the specs on the page for Element.querySelector, you can find a link to the spec here: https://dom.spec.whatwg.org/#dom-parentnode-queryselector