-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Observed (with Javascript tracing in Safari on a Mac):
- Change a text input value to something I know is invalid (in my case, it's one character too long, specified with both a
patternattribute and checked in a "check()" function) - @change event gets fired
- The event handler first sets the border colour to empty (
e.target.style.borderColor = "") - Then a check() function is called (still inside the change event handler)
- The function correctly identifies that there's a problem with the text and sets the element's
style.borderColorto"red" - I observe this change while stepping through the code — the border turns red
- The function exits — the border stays red, as desired
- Tracing goes to the element itself, and when I hit "step over", the input element goes back to having no border colour
I run through these steps again, and instead of "step over", I hit "step into" and trace the "undo my changes line" (in an un-minified arrow.js, (Source: https://cdn.skypack.dev/pin/@arrow-js/[email protected]/mode=imports/optimized/@arrow-js/core.js)):
function setNode(value, p) {
const isUpdate = typeof p === "function";
const partial = isUpdate ? p : createPartial();
Array.isArray(value) ? value.forEach((item) => measure("partialAdd", () => partial.add(item))) : partial.add(value);
if (isUpdate)
partial._up(); // <-- HEREThe code is getting a little complex for me, but I know that when that partial._up(); line is processed, the element has all my changes reverted.
Note that I also tried setting the className property when there's an error to "has-error" (accompanied by an input.has-error { border-color: red } style in a <style> section), and also tried adding to classList, but all three approaches (setting style.borderColor, setting className, and doing classList.add("has-error")) lead to the border colour being changed to red, followed by reverting to non-red when the change handler exits.
I tried making a small representative example, but that example doesn't fail, so it could either be my logic, or the error only happens when there's a much larger DOM tree. If you like, I'm happy to screen share and prove that exiting a change handler undoes my changes when inside the ArrowJS code.
Thanks again for a wonderful library! It's helping me get started with modern web page design.