madrobby / zepto

Zepto.js is a minimalist JavaScript library for modern browsers, with a jQuery-compatible API
http://zeptojs.com
Other
15k stars 3.93k forks source link

method html removes all data stored by $.fn.data #1339

Closed NesCafe62 closed 6 years ago

NesCafe62 commented 6 years ago

I also tried to make custom workaround. Has idea to add custom $.fn.dataHtml function with code similar to:

var data = el.getAllData();
el.html(html);
for (var key in data) {
  el.data(key, data[key]);
}

But there is no way to get all stored data keys. Maybe you can modernize $.data module to not lose data, or implement method to get all stored data or data keys for element. Right now I have to modify source code of $.data module which is not very good.

NesCafe62 commented 6 years ago

I made a mistake in another code, all works fine!