r/ProgrammerAnimemes • • Jan 01 '20

document.all

Post image
979 Upvotes

29 comments sorted by

View all comments

Show parent comment

3

u/HarJIT-EGS Jan 01 '20 edited Jan 01 '20

iirc, it's actually defined by the HTML spec… which specifically notes that it requires behaviour (in terms of the extent it pretends not to be defined) not provided for by anything in the ECMAScript spec.

Edit: also, something that wasn't mentioned above: IE exported elements by their IDs as attributes on both document.all and the global object (i.e. window), so it's not merely a list. Whereas Netscape 4 and down exported them as attributes on ancestor nodes, including document. Netscape 6 and up dropped this altogether in favour of the W3C model though.

5

u/bucket3432 Jan 01 '20

iirc, it's actually defined by the HTML spec… which specifically notes that it requires behaviour (in terms of the extent it pretends not to be defined) not provided for by anything in the ECMAScript spec.

That was the case until a year or two ago. The behaviour of document.all used to be defined in the WhatWG spec as a willful violation of the ECMA-262 spec, but as of ES2018, there's a new internal slot defined in Annex B called IsHTMLDDA that describes its behaviour, so it is no longer a willful violation.