Skip to content

Commit 5765d95

Browse files
authored
Haxe 5 compat.
1 parent 5ae6029 commit 5765d95

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/coconut/react/Key.hx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@ package coconut.react;
22

33
abstract Key(Dynamic) from String from Bool from Float from Int #if genes from {} #end {
44
#if !genes
5-
@:keep @:from static function ofObj(o:{}):Key untyped {
6-
var id = haxe.ds.ObjectMap.getId(o) || haxe.ds.ObjectMap.assignId(o);
7-
return id;
8-
}
5+
@:keep @:from static function ofObj(o:{}):Key {
6+
var id =
7+
#if (js_es >= 6)
8+
(cast o)[cast ID] ??= counter++;
9+
#else
10+
@:privateAccess (haxe.ds.ObjectMap.getId(o) || haxe.ds.ObjectMap.assignId(o));
11+
#end
12+
return id;
13+
}
14+
#if (js_es >= 6)
15+
static var counter = 0;
16+
static final ID = new js.lib.Symbol();
17+
#end
918
#end
10-
}
19+
}

0 commit comments

Comments
 (0)