madrobby/zepto — Issue #306: data(key, value) behaves unexpected
Author: ccoenen
Created: 2011-11-08 09:16:51+00:00
State: open

This is not really a bug, but something to stumble over: Storing an object with jQuery's data() function will store the object somewhere in the framework. You can store and retrieve arbitrary objects.

In Zepto, however, the data-...-attributes are used, which only allow strings to be stored. Thus any stored object will be converted to the string `[Object object]`, which, in turn, breaks many jQuery-plugins.

I think there should be some kind of obvious warning in the API (or even thrown by the function) that data may be lost. Right now it just states that the data-attribute is being used. But (in my opinion) ideal behaviour were, cloning jQuery's behaviour which works with complex objects as well.