forked from google/jsaction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.js
86 lines (68 loc) · 2.02 KB
/
cache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2013 Google Inc. All Rights Reserved.
/**
* @fileoverview A small library to share functions to get and set
* jsaction parser cache entries.
*/
goog.provide('jsaction.Cache');
goog.require('jsaction.Property');
/**
* Reads the jsaction parser cache from the given DOM Element.
*
* @param {!Element} element .
* @return {!Object.<string, string>} Map from event to qualified name
* of the jsaction bound to it.
*/
jsaction.Cache.get = function(element) {
return element[jsaction.Property.JSACTION];
};
/**
* Writes the jsaction parser cache to the given DOM Element.
*
* @param {!Element} element .
* @param {!Object.<string, string>} actionMap Map from event to
* qualified name of the jsaction bound to it.
*/
jsaction.Cache.set = function(element, actionMap) {
element[jsaction.Property.JSACTION] = actionMap;
};
/**
* Clears the jsaction parser cache from the given DOM Element.
*
* @param {!Element} element .
*/
jsaction.Cache.clear = function(element) {
if (jsaction.Property.JSACTION in element) {
delete element[jsaction.Property.JSACTION];
}
};
/**
* Reads the cached jsaction namespace from the given DOM
* Element. Undefined means there is no cached value; null is a cached
* jsnamespace attribute that's absent.
*
* @param {!Element} element .
* @return {string|null|undefined} .
*/
jsaction.Cache.getNamespace = function(element) {
return element[jsaction.Property.JSNAMESPACE];
};
/**
* Writes the cached jsaction namespace to the given DOM Element. Null
* represents a jsnamespace attribute that's absent.
*
* @param {!Element} element .
* @param {?string} jsnamespace .
*/
jsaction.Cache.setNamespace = function(element, jsnamespace) {
element[jsaction.Property.JSNAMESPACE] = jsnamespace;
};
/**
* Clears the cached jsaction namespace from the given DOM Element.
*
* @param {!Element} element .
*/
jsaction.Cache.clearNamespace = function(element) {
if (jsaction.Property.JSNAMESPACE in element) {
delete element[jsaction.Property.JSNAMESPACE];
}
};