UNPKG

1.1 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 */
8
9'use strict';
10
11/**
12 * `ReactInstanceMap` maintains a mapping from a public facing stateful
13 * instance (key) and the internal representation (value). This allows public
14 * methods to accept the user facing instance as an argument and map them back
15 * to internal methods.
16 */
17
18// TODO: Replace this with ES6: var ReactInstanceMap = new Map();
19
20var ReactInstanceMap = {
21 /**
22 * This API should be called `delete` but we'd have to make sure to always
23 * transform these to strings for IE support. When this transform is fully
24 * supported we can rename it.
25 */
26 remove: function (key) {
27 key._reactInternalInstance = undefined;
28 },
29
30 get: function (key) {
31 return key._reactInternalInstance;
32 },
33
34 has: function (key) {
35 return key._reactInternalInstance !== undefined;
36 },
37
38 set: function (key, value) {
39 key._reactInternalInstance = value;
40 }
41};
42
43module.exports = ReactInstanceMap;
\No newline at end of file