fix(lexical): guard klass.prototype null check in getStaticNodeConfig#8726
Conversation
getStaticNodeConfig() uses the `in` operator on `klass.prototype` without checking that it is non-null. When the extends-chain traversal reaches a class whose prototype is undefined (e.g. a functional component or exotic constructor), this throws: TypeError: Cannot use 'in' operator to search for '$config' in undefined Add a null guard so the lookup safely falls through to `undefined` instead of throwing. Fixes a regression introduced in #8716 (Named-slot typing).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
This seems fine but I’d like to see an example of an object that is a valid node and crashes without this patch
|
AFAICT this only serves to improve the error message, I can't think of a scenario where this fix changes any behavior. |
Error: Possible Root cause: #8716 (Named-slot typing). The Fix: OSS guard in - const nodeConfigRecord = PROTOTYPE_CONFIG_METHOD in klass.prototype ? ...
+ const nodeConfigRecord = klass.prototype != null && PROTOTYPE_CONFIG_METHOD in klass.prototype ? ... |
Summary
getStaticNodeConfig()uses theinoperator onklass.prototypewithout checking that it is non-null. When the extends-chain traversal reaches a class whose prototype is undefined (e.g. a functional component or exotic constructor), this throws:Fix
Add a null guard so the lookup safely falls through to
undefinedinstead of throwing:Context
This is a regression introduced in #8716 (Named-slot typing). The crash surfaces when
createEditor()traverses the$config.extendschain and walks past a proper class boundary whereklass.prototypeis undefined.