Return undefined
instead of Dict.empty
from Page.getInheritedPageProp
for non-existent properties to prevent possible future bugs
#8129
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.
This is something that I noticed while working on PR #8126, which is (more) fallout from PR #6065.
In general, it's actually not correct to return
Dict.empty
as the default value for non-existent properties. Please note that a prior PR, see #5957 (comment), asked for that behaviour but I don't think that's right.Obviously for properties that are (or should) be
Dict
s it makes sense, however certain properties can be e.g. Strings or Arrays instead. In the latter case, returningDict.empty
is just plain wrong, and it's quite fascinating that this hasn't caused any errors in practice. (The existing validation in the various getters has actually saved us here.)Also, when looking at this code again, it seemed unnecessary to duplicate the
MAX_LOOP_COUNT
check since we could just return immediately instead.