HTML5-placeholder-polyfill
HTML5-placeholder-polyfill copied to clipboard
Reduce CSS changes when input is focused
When an input is focused, the requestAnimationFrame check loop should change CSS only when it is necessary.
So instead of repeatedly calling showPlaceholderIfEmpty()
(which calls removeClass()
or addClass()
all the time) in the check loop, we should polling input.val()
and call hidePlaceholder()
or showPlaceholder()
only when the boundary condition is satisfied.