Skip to content

Release - v2.2.13 #3003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,17 @@ module.exports = function() {
if (key === "value") {
// Only do the coercion if we're actually going to check the value.
/* eslint-disable no-implicit-coercion */
var isFileInput = vnode.tag === "input" && vnode.attrs.type === "file"
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome
//setting input[type=file][value] to same value causes an error to be generated if it's non-empty
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === "" + value && (isFileInput || vnode.dom === activeElement(vnode.dom))) return
//minlength/maxlength validation isn't performed on script-set values(#2256)
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === "" + value) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select" && old !== null && vnode.dom.value === "" + value) return
//setting option[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return
//setting input[type=file][value] to different value is an error if it's non-empty
// Not ideal, but it at least works around the most common source of uncaught exceptions for now.
if (isFileInput && "" + value !== "") { console.error("`value` is read-only on file inputs!"); return }
if (vnode.tag === "input" && vnode.attrs.type === "file" && "" + value !== "") { console.error("`value` is read-only on file inputs!"); return }
/* eslint-enable no-implicit-coercion */
}
// If you assign an input type that is not supported by IE 11 with an assignment expression, an error will occur.
Expand Down
49 changes: 49 additions & 0 deletions render/tests/manual/minlength-input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
This is minlength validity test (#2256).
Open your browser's Developer Console and follow these steps:
<ol>
<li>Type any (1 or 2) characters in the input field.</li>
<li>Click “submit.”</li>
<li>Click “submit” again.</li>
<li>Check the logs displayed in the console.</li>
</ol>

<div id="root"></div>
<script src="../../../mithril.js"></script>
<script>
let input, value;

m.mount(document.getElementById("root"), {
view: () => [
input = m("input[type=text]", {
value,
minLength: 4,
required: true,
oninput(e) {
value = e.target.value;
check();
}
}),
m("button", {
onclick(e) {
console.log("click");
check();
}
}, "submit")
],
});

function check() {
console.log(`tooShort: ${input.dom.validity.tooShort}`,
`valueMissing: ${input.dom.validity.valueMissing}`,
`checkValidity: ${input.dom.checkValidity()}`
);
}
</script>
</body>
</html>
49 changes: 49 additions & 0 deletions render/tests/manual/minlength-textarea.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
This is minlength validity test (#2256).
Open your browser's Developer Console and follow these steps:
<ol>
<li>Type any (1 or 2) characters in the textarea field.</li>
<li>Click “submit.”</li>
<li>Click “submit” again.</li>
<li>Check the logs displayed in the console.</li>
</ol>

<div id="root"></div>
<script src="../../../mithril.js"></script>
<script>
let input, value;

m.mount(document.getElementById("root"), {
view: () => [
input = m("textarea", {
value,
minLength: 4,
required: true,
oninput(e) {
value = e.target.value;
check();
}
}),
m("button", {
onclick(e) {
console.log("click");
check();
}
}, "submit")
],
});

function check() {
console.log(`tooShort: ${input.dom.validity.tooShort}`,
`valueMissing: ${input.dom.validity.valueMissing}`,
`checkValidity: ${input.dom.checkValidity()}`
);
}
</script>
</body>
</html>
Loading