#6298 #6263 -importing tests from PR #6298, as written by @erispre

Note that attribution will be given only as a comment to the commit, since rebasing/squashing
the commits to avoid changes to unaffected code-paths is problematic.

If this doesn't match expectations, then please ask for a revert and send the test code in a separate
pull request.
Merge branch 'hotfix/#6298-#6263-handle-regular-elements-as-target-of-collection-element'

Close #6298