You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #523 [Live] Fixed bug with "unsynced" inputs and <form data-model> (weaverryan)
This PR was squashed before being merged into the 2.x branch.
Discussion
----------
[Live] Fixed bug with "unsynced" inputs and <form data-model>
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Tickets | none
| License | MIT
This fixes an unreleased bug. In a somewhat edge-case use with forms, as you typed into the fields, the values you were typing would get run-over/replaced by the old values from the server - i.e. some of what you are typing gets deleted as you type. That ends up being 0️⃣ fun!
The technical details:
> If a field is modified during an Ajax request, previously, for model fields, after re-rendering, the modified values from the ValueStore were set back onto those fields via SetValueOntoModelFieldsPlugin. Effectively, morphdom would use the new value from the server (which is not correct) momentarily, and then we would reset it back to the modified value.
> However, that didn't work for fields inside of a <form data-model> that use the name attribute, as the "auto-set model field values" functionality purposely doesn't apply to those.
> So, the system was made smarter. It now keeps track of *all* field elements that have been modified (i.e. are unsynced). Then, only when those values are actually *sent* to the server on an Ajax request, those are removed as unsynced elements. This means that morphdom will now see all unsynced fields during re-rendering and will prefer the browser values over the server values.
Cheers!
Commits
-------
ecf124f [Live] Fixed bug with "unsynced" inputs and <form data-model>
if(kind==="a"&&!f)thrownewTypeError("Private accessor was defined without a getter");
1258
-
if(typeofstate==="function" ? receiver!==state||!f : !state.has(receiver))thrownewTypeError("Cannot read private member from an object whose class did not declare it");
1259
-
returnkind==="m" ? f : kind==="a" ? f.call(receiver) : f ? f.value : state.get(receiver);
if(kind==="m")thrownewTypeError("Private method is not writable");
1264
-
if(kind==="a"&&!f)thrownewTypeError("Private accessor was defined without a setter");
1265
-
if(typeofstate==="function" ? receiver!==state||!f : !state.has(receiver))thrownewTypeError("Cannot write private member to an object whose class did not declare it");
1266
-
return(kind==="a" ? f.call(receiver,value) : f ? f.value=value : state.set(receiver,value)),value;
0 commit comments