0

Is there any standard for WEB/DOM/BOM API which all browsers adhere to? Something like ECMAScript.

var aElements = document.querySelectorAll('a');

How to make sure the line mentioned above works across the browsers I intend to support?

Asons
  • 84,923
  • 12
  • 110
  • 165
Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
  • 2
    Yes, see e.g. https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll, under "Specifications" – georg Oct 05 '19 at 09:02
  • 1
    Also, a useful resource for quick checking: https://caniuse.com/#feat=queryselector – VLAZ Oct 05 '19 at 09:03
  • 1
    https://dom.spec.whatwg.org, but standards don’t tell the whole browser support story. For that, see sites like https://caniuse.com. – Ry- Oct 05 '19 at 09:03
  • Does W3C has anything to do with dom? I also found https://en.m.wikipedia.org/wiki/Comparison_of_JavaScript_engines_(DOM_support) . Is it reliable? – Ahmad Ismail Oct 05 '19 at 09:09
  • 1
    @blueray W3 and WHATWG are different organisations, where WHATWG sprung from the former because they didn't like the way W3 was governed and the way it developed standards. They still compete in the sense that W3 these days aligns some of their specifications with what WHATWG publishes, but which is _the_ authority on an API cannot be answered -- those who make Web browsers have to decide that themselves as they implement APIs. In short -- yes, there is a DOM standard, actually many, by at least two standards bodies. – Armen Michaeli Oct 05 '19 at 10:04

1 Answers1

1

Theoretically, yes (in most cases), there is standards.

Practically, no, you can't be sure something works cross browser. For that you need to test it on all you intend to support.

Below you find some useful links, where others have made some of these tests, and put it together, to make life somewhat simpler for us developers...so a big Thank you to them, as official resources can be a pain to read and understand.

The reason is quite simple, browser manufacturer can, and sometimes do, interpret set standards in their own way, which can lead to different behavior (often called "browser bugs").

There is also the time between a given standard is set to take into account, and for all manufacturer to actually implement it. This is often where prefixed properties comes into play, before drafted new/updated properties have been standardized.

Some useful links:

Asons
  • 84,923
  • 12
  • 110
  • 165
  • What is https://dom.spec.whatwg.org & https://www.w3.org/TR/2015/REC-dom-20151119/ – Ahmad Ismail Oct 05 '19 at 09:42
  • 1
    @blueray -- They are new and old versions of the same. The first is where we are at today, the second is where we were 4 years ago. In the second/old there's a link labeled "Latest published version:". Click that and you get to the first/new address. – Asons Oct 05 '19 at 09:54