Update directive.js

optimize directive.js as my clue