Fixes #3162 : improve javascript for directive modified diff