Closed ljharb closed 6 years ago
This was discussed in https://github.com/drufball/layered-apis/issues/6#issuecomment-386650536; definitely on a TODO to explain more. The basic idea is that we don't want to prevent future refactorings on the platform that would move things between prototypes.
Wouldn't that still be the case tho, if someone did callOriginalMethod(originalArrayPrototype, 'slice', receiver)
, and the method name was moved?
No, there is no thisArg in the method signature. You need to operate on instances directly.
ok, so it'd be like "call the original slice method on an array" - and when you say "move things between prototypes", you mean "within levels of the prototype chain" but not "off of the chain entirely"?
Right. A specific concern is that browsers are moving various things between HTMLDocument.prototype and Document.prototype, and the set of which goes where is not interoperable currently. We hope developers don't have to care about this---just supply (the original value of the global) document, and a method/property name, and you'll get the right answer, no matter where the particular browser you're dealing with has put that method/property.
Makes sense.
Altho, the internal mapping could be 'Old.prototype.method'
→ getOriginal('New.prototype.method')
- but the rationale makes sense, so I'll close.
For example,
callOriginalMethod('Array.prototype.slice', receiver, ...args)
instead of needing to storeArray.prototype
in the first place?