Placeholders.js
Placeholders.js copied to clipboard
IE8 placeholders for password (acceptable fix? optional fix?)
IE8 hides text of password. I rather think it should not show it at all as it is very confusing for the user. One can chose to remove password from validTypes array, but then it does not work for IE9 either.
My solution was to modify showPlaceholder like this to make a check if it was possible to change type of password to text.
I basicly moved to "set value" part to after the changeType was called. If changeType fails the method returns false instead and never sets the value.
function showPlaceholder(elem) {
var type,
maxLength,
val = elem.getAttribute(ATTR_CURRENT_VAL);
if (elem.value === "" && val) {
// If the type of element needs to change, change it (e.g. password inputs)
type = elem.getAttribute(ATTR_INPUT_TYPE);
if (type) {
elem.type = "text";
} else if (elem.type === "password") {
if (Utils.changeType(elem, "text")) {
elem.setAttribute(ATTR_INPUT_TYPE, "password");
}
else
{
return false;
}
}
elem.setAttribute(ATTR_ACTIVE, "true");
elem.value = val;
elem.className += " " + placeholderClassName;
// Store and remove the maxlength value
maxLength = elem.getAttribute(ATTR_MAXLENGTH);
if (!maxLength) {
elem.setAttribute(ATTR_MAXLENGTH, elem.maxLength);
elem.removeAttribute("maxLength");
}
return true;
}
return false;
}
I am open to removing the password functionality when it is not supported (as you say that is easy to detect because the type
attribute won't change). However I think it should be a configurable option and should probably work by splicing the password
type out of the validTypes
array at run time. I'll have a look into this for the next version which I hope to release within the next few days.
I agree that opt-out is probably the best as it won't break current usage. Thanks for the fast feedback, it's a really useful polyfill.
Was a change made here?
In IE8 when i try to modify the type of the element the below line is throwing error
elem.type = "text"
could you fix this?
let type
=password
also show placeholders
I think this is really a big problem..hope someone fix it.
plz fix it!
It seems that nobody maintain this repository at all.
T_T please fix it