Repository navigation
refactor(markdown-toolkit): detect elements in isMDElement - #195
Merged
Merged
Conversation
`renderingOf` did two jobs: it read an element's stored nodes and style, and callers also used its `undefined` result to test whether a value is an element at all. The test now lives in `isMDElement`, which checks for the key directly, and the five places that tested through `renderingOf` call it instead. Its type guard removes three casts. `renderingOf` is unchanged and now only serves the places that read from it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
renderingOfdid two jobs: it read an element's stored nodes and style, and itsundefinedresult doubled as the test for "is this an element?". The test now lives inisMDElement, and the places that tested throughrenderingOfcall it. No behavior changes.Changes
Detection moved.
isMDElementchecks for the element key itself, instead of askingrenderingOfand comparing withundefined.Test sites switched. These five now call
isMDElement:isKinddescribeisFrontmatterisPlainObjectisTemplateReplacementThe type guard narrows the value, so three
as MDElement/as MDFrontmattercasts are gone.Left for a follow-up.
renderingOfis unchanged. It still takesunknownand returnsundefinedfor a non-element, for the ten places that read nodes or style from it. Three of those (inlineNodes,blockNodes,substitutePlaceholders) still lean on thatundefined; they change together with the getter.