Is there an error in the judgment criteria in Object.defineProperty?
The request link I am using: https://polyfill.io/v3/polyfill.js?flags=always
Errors during use:
This method is not used in my code, it may be used by other third-party libraries. But it can work normally in modern browsers without introducing polyfill.
We do not recommend using only flags=always - it will cause issues. If wanting to always serve polyfills, we highly recommend using it in combination with gated like so, flags=always,gated, that way we will only apply a polyfill if the feature was not already present in the browser
@JakeChampion Thank you for your suggestion. I actually used only the method I needed to fill in, but in any case, the code I marked in the figure is incorrect.
Could you please explain what is incorrect, it looks correct to me
@JakeChampion
// https://polyfill.io/v3/polyfill.js?flags=always
...
var getterType = 'get' in descriptor && typeof descriptor.get; // getterType can never be undefined
var setterType = 'set' in descriptor && typeof descriptor.set; // setterType can never be undefined
if (getterType) { // This judgment means that the following judgment should not have undefined
if (getterType === undefined) { // getterType can never be undefined, but it may be "undefined"
return object;
}
...
}
if (setterType) {
if (setterType === undefined) {
return object;
}
...
}
In the image of my original question, the comments I added in the above code are well explained.
Perhaps I misunderstood the above code judgment? But it was indeed executed like this.
It should be noted that the undefined here is actually two different things: one is the data type, and the other is the string.