-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (44 loc) · 836 Bytes
/
index.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
/**
* Element
* Element dataset component
*
* @copyright 2013 Enrico Marino
* @license MIT
*/
/**
* dataset
* Get/Set value.
*
* @param {Mixed} [value] value to set
* @api public
*/
exports.data = function (attribute, value) {
if (1 == arguments.length) {
return this.set_data(attribute, value);
}
return this.get_data(attribute);
};
/**
* get_data
* Get data.
*
* @param {String} attribute attribute
* @return {Mixed} the value.
* @api public
*/
exports.get_data = function (attribute) {
return this.el.dataset[attribute];
};
/**
* set_data
* Set data.
*
* @param {String} attribute attribute
* @param {Mixed} value value to set
* @return {Element} this for chaining
* @api public
*/
exports.set_data = function (attribute, value) {
this.el.dataset[attribute] = value;
return this;
};