diff --git a/lib/javascript-static.js b/lib/javascript-static.js
index 929a477d3ce..50d48b8e4ae 100644
--- a/lib/javascript-static.js
+++ b/lib/javascript-static.js
@@ -1022,34 +1022,54 @@ function findChildNodes(start, tagName, elementClass, elementID, elementName) {
}
function unmaskPassword(id) {
- var pw = document.getElementById(id);
- var chb = document.getElementById(id+'unmask');
+ var pw = document.getElementById(id);
+ var chb = document.getElementById(id+'unmask');
+ var IEbrowser = navigator.userAgent.toLowerCase().indexOf('msie');
+ var IEversion = 0;
- try {
- // first try IE way - it can not set name attribute later
- if (chb.checked) {
- var newpw = document.createElement('');
- } else {
- var newpw = document.createElement('');
+ if (IEbrowser != -1) {
+ var position = navigator.userAgent.indexOf("MSIE") + 5;
+ var end = navigator.userAgent.search("; Windows");
+ IEversion = parseInt(navigator.userAgent.substring(position,end));
}
- newpw.attributes['class'].nodeValue = pw.attributes['class'].nodeValue;
- } catch (e) {
- var newpw = document.createElement('input');
- newpw.setAttribute('autocomplete', 'off');
- newpw.setAttribute('name', pw.name);
- if (chb.checked) {
- newpw.setAttribute('type', 'text');
- } else {
- newpw.setAttribute('type', 'password');
+
+ // MDL-30438 - The capability to changing the value of input type is not supported by IE8 or lower.
+ // Replacing existing child with a new one, removed all yui properties for the node. Therefore, this
+ // functionality won't work in IE8 or lower.
+ // This is a temporary fixed for 2.4 or lower branches to allow other browsers to function properly.
+ if (IEbrowser == -1 || (IEversion >= 9)) {
+ if (chb.checked) {
+ pw.type = "text";
+ } else {
+ pw.type = "password";
+ }
+ } else { //IE Browser version 8 or lower
+ try {
+ // first try IE way - it can not set name attribute later
+ if (chb.checked) {
+ var newpw = document.createElement('');
+ } else {
+ var newpw = document.createElement('');
+ }
+ newpw.attributes['class'].nodeValue = pw.attributes['class'].nodeValue;
+ } catch (e) {
+ var newpw = document.createElement('input');
+ newpw.setAttribute('autocomplete', 'off');
+ newpw.setAttribute('name', pw.name);
+ if (chb.checked) {
+ newpw.setAttribute('type', 'text');
+ } else {
+ newpw.setAttribute('type', 'password');
+ }
+ newpw.setAttribute('class', pw.getAttribute('class'));
+ }
+ newpw.id = pw.id;
+ newpw.size = pw.size;
+ newpw.onblur = pw.onblur;
+ newpw.onchange = pw.onchange;
+ newpw.value = pw.value;
+ pw.parentNode.replaceChild(newpw, pw);
}
- newpw.setAttribute('class', pw.getAttribute('class'));
- }
- newpw.id = pw.id;
- newpw.size = pw.size;
- newpw.onblur = pw.onblur;
- newpw.onchange = pw.onchange;
- newpw.value = pw.value;
- pw.parentNode.replaceChild(newpw, pw);
}
function filterByParent(elCollection, parentFinder) {