|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
536 bytes
|
| Rev | Line | |
|---|
| [e4c61dd] | 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 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.