You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid overly-cautious type guards in favor of more performant type discriminators (#5982)
* add `isEditorNode`, `isElementNode`, and `isTextNode` and switch to using them whenever possible.
also switch to `node === editor` checks where it makes sense
also add a comment to a confusing failure state of `Node.parent`
also remove a superfluous call to `Editor.nodes` in certain codepaths of `Editor.wrapNodes`
* fix deep checking for `isEditor` and check for new properties from #5307
* convert all instances of `Element.isAncestor` and a few I missed before
* changeset
* fix pretter complaint in changeset
* use new guards in other packages and examples
* revert wrap nodes change (keeping new guards)
* add other packages to changeset
* preemptively update peerDependencies
* renamed isXNode functions to Node.isX
* replaced a few places where isText is passed as a value directly
* removed unneeded imports
* update yarn lock so tests can pass
* added `Node.isAncestor` sugar function
* update jsx examples
Add `Node.isEditor`, `Node.isElement`, and `Node.isText` as alternative type guards for when we already know the object is a node.
8
+
Use these new functions instead of `Editor.isEditor`, `Element.isElement`, and `Text.isText` whenever possible, the classic functions are only necessary for typechecking an entirely unknown object.
0 commit comments