1 | var nextId = 0;
|
2 |
|
3 | export default function local() {
|
4 | return new Local;
|
5 | }
|
6 |
|
7 | function Local() {
|
8 | this._ = "@" + (++nextId).toString(36);
|
9 | }
|
10 |
|
11 | Local.prototype = local.prototype = {
|
12 | constructor: Local,
|
13 | get: function(node) {
|
14 | var id = this._;
|
15 | while (!(id in node)) if (!(node = node.parentNode)) return;
|
16 | return node[id];
|
17 | },
|
18 | set: function(node, value) {
|
19 | return node[this._] = value;
|
20 | },
|
21 | remove: function(node) {
|
22 | return this._ in node && delete node[this._];
|
23 | },
|
24 | toString: function() {
|
25 | return this._;
|
26 | }
|
27 | };
|