* 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)
| 993 | */ |
| 994 | |
| 995 | function escape(key) { |
| 996 | var escapeRegex = /[=:]/g; |
| 997 | var escaperLookup = { |
| 998 | '=': '=0', |
| 999 | ':': '=2' |
| 1000 | }; |
| 1001 | var escapedString = ('' + key).replace(escapeRegex, function (match) { |
| 1002 | return escaperLookup[match]; |
| 1003 | }); |
| 1004 | return '$' + escapedString; |
| 1005 | } |
| 1006 | /** |
| 1007 | * TODO: Test that a single child and an array with one item have the same key |
| 1008 | * pattern. |
no test coverage detected