Ensure that the shadow
helper function is passed a valid property (PR 14152 follow-up)
Trying to shadow a non-existent property is always an implementation mistake, since it leads to the `shadow`-call not having any effect. In PR 14152 I overlooked the fact that it's fairly easy to enforce this during development/testing, since that can help catch e.g. simple spelling bugs.
This commit is contained in:
parent
e9e4b913c0
commit
d9fac34596
@ -488,6 +488,15 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
|
||||
}
|
||||
|
||||
function shadow(obj, prop, value) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||
) {
|
||||
assert(
|
||||
prop in obj,
|
||||
`shadow: Property "${prop && prop.toString()}" not found in object.`
|
||||
);
|
||||
}
|
||||
Object.defineProperty(obj, prop, {
|
||||
value,
|
||||
enumerable: true,
|
||||
|
Loading…
Reference in New Issue
Block a user