* Escape and wrap key so it is safe to use as a reactid * * @param {string} key to be escaped. * @return {string} the escaped key.
(key)
| 18974 | * @return {string} the escaped key. |
| 18975 | */ |
| 18976 | function escape(key) { |
| 18977 | var escapeRegex = /[=:]/g; |
| 18978 | var escaperLookup = { |
| 18979 | '=': '=0', |
| 18980 | ':': '=2' |
| 18981 | }; |
| 18982 | var escapedString = ('' + key).replace(escapeRegex, function (match) { |
| 18983 | return escaperLookup[match]; |
| 18984 | }); |
| 18985 | |
| 18986 | return '$' + escapedString; |
| 18987 | } |
| 18988 | |
| 18989 | /** |
| 18990 | * TODO: Test that a single child and an array with one item have the same key |
no outgoing calls
no test coverage detected