<!DOCTYPE html>
<html>
<body onload="b.dir='auto'; a.dir='auto'; b.remove();">
<bdi id="a"><span id="b">f</span>g</bdi>
</body>
</html>