jamesallardice / Placeholders.js

A JavaScript polyfill for the HTML5 placeholder attribute
http://jamesallardice.github.io/Placeholders.js
950 stars 232 forks source link

IE8/9 Placeholders.disable() retains focus/blur event listeners #86

Open chriswetterman opened 9 years ago

chriswetterman commented 9 years ago

This probably affects all browsers but in my testing calling Placeholders.disable( elem ) removes the placeholder as expected, but subsequently giving the input field focus and then blurring with the mouse restores the placeholder value on the empty field. My expectation of calling Placeholder.disable( elem ) is that placeholder behavior will not return until Placeholder.enable( elem ) is explicitly called. Looking through the code it appears there is no removeEventListener support for focus/blur events and that is what's needed to resolve this issue when calling Placeholder.disable().

jamesallardice commented 9 years ago

The method is perhaps named badly. It will hide the placeholder for the given element (or all elements if none are passed to it) but not actually "disable" the functionality. Thanks for reporting this... I'd never really considered it! I'll think about the best way to improve it.