Changing you local variable does not change the stored data. If you want to change the stored data, call .data() with two parameters.
While you didn't ask... nor does changing the stored data (using .data() with two parameters) change the attribute in the DOM.
The DOM attribute INITIALIZES the internal data store for .data() on first reference.
I do agree perhaps it could use more clear documentation. Maybe it should be made clear that .data() doesn't pass back a reference to it's internal data store, but (apparently) a reference to a new object with a copy of the internal data.
The problem is .data is returning a reference to the cache. I can modify the cache directly after calling .data once without invoking .data() again.
Subsequent calls to .data() show the side effects of changes to the cache even though the original operation was a read operation. By giving me direct access to the data object I mutate an object which I assumed I was only given a copy of.
There's no mention of the cache system in the documentation, so it really threw me for a loop.
I still have no idea what the problem is. There is no "cache system", there is a "data object" that you get each time that you ask for it. The demo behavior looks totally correct to me. You assigned a value to a property and it is still there when you check for it. Why would the assignment statement _json.is_persisting = false fail to work?
Because I'm supposed to over write it with a subsequent call to .data(). Instead I get a reference to the dirty object. There's nothing in the documentation that would lead you to expect this behavior.
Also, why are you so insistent that there's no cache. I have a source of data, the DOM. I have something that makes a copy of this data. The copy persists and does not allow subsequent read to reach the original data source. That's the definition of a cache.
OK, I was wrong... it returns a reference to the internal data. So, you CAN change the data by changing your variable.
Sorry, I was struggling to understand what the Fiddle was trying to prove, and mis-read it. I thought OP was complaining that changing his variable did not change the internal data.
It is not a cache, in that changes to the attribute will NOT change the internal data associated with the node. It is simply "data associated with a node", that happens to be INITIALIZED from the attribute value.