Skip to content

Commit 430167b

Browse files
committed
fix(lib dependshandler): Do not return the value from an disabled input. Return null instead.
1 parent d2c0960 commit 430167b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/lib/dependshandler.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class DependsHandler {
3434
if (input.type === "checkbox" && input.checked === false) {
3535
return false;
3636
}
37+
if (input.disabled) {
38+
return false;
39+
}
3740
return true;
3841
});
3942

src/lib/dependshandler.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,42 @@ describe("pat-dependshandler", function () {
103103
});
104104

105105
describe("_getValue", function () {
106+
it("Just get the text value.", function () {
107+
document.body.innerHTML = `
108+
<div id="lab">
109+
<input name="foo" value="bar"/>
110+
</div>
111+
`;
112+
const lab = document.getElementById("lab");
113+
const handler = new DependsHandler(lab, "foo");
114+
115+
expect(handler._getValue("foo")).toBe("bar");
116+
});
117+
118+
it("Get an empty value from an empty input.", function () {
119+
document.body.innerHTML = `
120+
<div id="lab">
121+
<input name="foo" value=""/>
122+
</div>
123+
`;
124+
const lab = document.getElementById("lab");
125+
const handler = new DependsHandler(lab, "foo");
126+
127+
expect(handler._getValue("foo")).toBe("");
128+
});
129+
130+
it("Get null from a disabled input.", function () {
131+
document.body.innerHTML = `
132+
<div id="lab">
133+
<input name="foo" value="bar" disabled/>
134+
</div>
135+
`;
136+
const lab = document.getElementById("lab");
137+
const handler = new DependsHandler(lab, "foo");
138+
139+
expect(handler._getValue("foo")).toBe(null);
140+
});
141+
106142
it("Unchecked checkbox returns no value", function () {
107143
document.body.innerHTML = `
108144
<div id="lab">

0 commit comments

Comments
 (0)