Alter element storage API to handle the window
object gracefully.
This commit is contained in:
parent
3977e66796
commit
77b9a2614a
@ -1,4 +1,4 @@
|
||||
* Added Element#store and Element#retrieve for safe, hash-backed storage of element metadata (no memory leaks). Also added Element#getStorage for working with the element's storage hash directly. Hat tip: Mootools. (ZenCocoon, Andrew Dupont)
|
||||
* Add Element#store and Element#retrieve for safe, hash-backed storage of element metadata (no memory leaks). Also add Element#getStorage for working with the element's storage hash directly. Hat tip: Mootools. (ZenCocoon, Andrew Dupont)
|
||||
|
||||
* Fix issue where certain versions of Safari treat class names case-insensitively in Selector/$$ queries. (Andrew Dupont, kangax, Brice)
|
||||
|
||||
|
@ -1214,11 +1214,15 @@ Element.addMethods({
|
||||
getStorage: function(element) {
|
||||
if (!(element = $(element))) return;
|
||||
|
||||
if (Object.isUndefined(element._prototypeUID))
|
||||
element._prototypeUID = [Element.Storage.UID++];
|
||||
|
||||
var uid = element._prototypeUID[0];
|
||||
|
||||
var uid;
|
||||
if (element === window) {
|
||||
uid = 0;
|
||||
} else {
|
||||
if (Object.isUndefined(element._prototypeUID))
|
||||
element._prototypeUID = [Element.Storage.UID++];
|
||||
uid = element._prototypeUID[0];
|
||||
}
|
||||
|
||||
if (!Element.Storage[uid])
|
||||
Element.Storage[uid] = $H();
|
||||
|
||||
@ -1232,8 +1236,7 @@ Element.addMethods({
|
||||
|
||||
retrieve: function(element, key, defaultValue) {
|
||||
if (!(element = $(element))) return;
|
||||
|
||||
var hash = element.getStorage(), value = hash.get(key);
|
||||
var hash = Element.getStorage(element), value = hash.get(key);
|
||||
|
||||
if (Object.isUndefined(value)) {
|
||||
hash.set(key, defaultValue);
|
||||
|
Loading…
Reference in New Issue
Block a user