You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
536 B
27 lines
536 B
var nextId = 0; |
|
|
|
export default function local() { |
|
return new Local; |
|
} |
|
|
|
function Local() { |
|
this._ = "@" + (++nextId).toString(36); |
|
} |
|
|
|
Local.prototype = local.prototype = { |
|
constructor: Local, |
|
get: function(node) { |
|
var id = this._; |
|
while (!(id in node)) if (!(node = node.parentNode)) return; |
|
return node[id]; |
|
}, |
|
set: function(node, value) { |
|
return node[this._] = value; |
|
}, |
|
remove: function(node) { |
|
return this._ in node && delete node[this._]; |
|
}, |
|
toString: function() { |
|
return this._; |
|
} |
|
};
|
|
|