* 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)
| 18304 | * @return {string} the escaped key. |
| 18305 | */ |
| 18306 | function escape(key) { |
| 18307 | var escapeRegex = /[=:]/g; |
| 18308 | var escaperLookup = { |
| 18309 | '=': '=0', |
| 18310 | ':': '=2' |
| 18311 | }; |
| 18312 | var escapedString = ('' + key).replace(escapeRegex, function (match) { |
| 18313 | return escaperLookup[match]; |
| 18314 | }); |
| 18315 | |
| 18316 | return '$' + escapedString; |
| 18317 | } |
| 18318 | |
| 18319 | /** |
| 18320 | * TODO: Test that a single child and an array with one item have the same key |
no outgoing calls
no test coverage detected