Fix #13596; #13722: .replaceWith consistency. Close gh-1216.