Skip to content

Commit 00a0b9a

Browse files
committed
Disallow masked/password fields from being upgraded to multiline input
1 parent 188ccd6 commit 00a0b9a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

js/micron-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ applyStyleToElement(el, style, defaultBg = "default") {
987987
if (!input || !input.tagName || input.tagName.toLowerCase() === "textarea") return input;
988988
const owner = input.ownerDocument || (typeof document !== "undefined" ? document : null);
989989
if (!owner) return input;
990+
const inputType = (input.type || "").toLowerCase();
991+
if (inputType === "password") return input;
990992

991993
const ta = owner.createElement("textarea");
992994
ta.name = input.name;
@@ -1129,7 +1131,8 @@ applyStyleToElement(el, style, defaultBg = "default") {
11291131
const el = e.target;
11301132
if (!el || el.tagName !== "INPUT") return;
11311133
const t = (el.type || "text").toLowerCase();
1132-
if (t !== "text" && t !== "password" && t !== "") return;
1134+
if (t === "password") return;
1135+
if (t !== "text" && t !== "") return;
11331136
if (filter && !filter(el)) return;
11341137

11351138
const now = Date.now();
@@ -1186,7 +1189,7 @@ applyStyleToElement(el, style, defaultBg = "default") {
11861189
if (typeof selectorOrPredicate === "string") {
11871190
candidates = Array.from(root.querySelectorAll(selectorOrPredicate));
11881191
} else if (typeof selectorOrPredicate === "function") {
1189-
const all = Array.from(root.querySelectorAll('input[type="text"], input[type="password"], input:not([type])'));
1192+
const all = Array.from(root.querySelectorAll('input[type="text"], input:not([type])'));
11901193
for (const el of all) {
11911194
const info = {
11921195
name: el.name,
@@ -1213,6 +1216,7 @@ applyStyleToElement(el, style, defaultBg = "default") {
12131216

12141217
const upgraded = [];
12151218
for (const el of candidates) {
1219+
if (el && el.type && el.type.toLowerCase() === "password") continue;
12161220
const opts = el._micronUpgradeOpts || options;
12171221
if (el._micronUpgradeOpts) delete el._micronUpgradeOpts;
12181222
upgraded.push(MicronParser.upgradeInputToTextarea(el, opts));

0 commit comments

Comments
 (0)