domenic / get-originals

A web platform API that allows access to the "original" versions of the global built-in objects' properties and methods
28 stars 1 forks source link

There is no decent way to get the original values of WebIDL constants #9

Open bzbarsky opened 6 years ago

bzbarsky commented 6 years ago

getOriginalProperty doesn't allow a target that is a WebIDL prototype or constructor. So to use it to get a constant you have to get an instance of that interface and that as target.

None of the other APIs being introduced here return WebIDL constants.

domenic commented 6 years ago

Yeah, this is intentionally noted as not a supported capability:

// Non-method statics: use the actual constant values instead

Do you think we should make this clearer? Or, do you think this capability is important and we should make it possible somehow?

bzbarsky commented 6 years ago

It's only important in the sense of making it simpler to write code using these primitives.

That said, I guess if you want to do Node.DOCUMENT_NODE you can get the original Node constructor and then just get its .DOCUMENT_NODE. It's non-configurable and non-writable so this is safe... as long as you know for sure it's there at all.