The changes implemented in T13555: .mw-editsection links should not be part of the <h#> element (see "Heading HTML changes") can be enabled or disabled using the config setting $wgParserEnableLegacyHeadingDOM.
As documented in the release notes at the time, and on that documentaton page, in a future release after they are enabled by default, we should remove that config setting. This is tentatively planned for MediaWiki 1.45.