MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / escape

Function escape

code/styling/public/app.js:18982–18993  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

18980 * @return {string} the escaped key.
18981 */
18982function escape(key) {
18983 var escapeRegex = /[=:]/g;
18984 var escaperLookup = {
18985 '=': '=0',
18986 ':': '=2'
18987 };
18988 var escapedString = ('' + key).replace(escapeRegex, function (match) {
18989 return escaperLookup[match];
18990 });
18991
18992 return '$' + escapedString;
18993}
18994
18995/**
18996 * TODO: Test that a single child and an array with one item have the same key

Callers 4

getComponentKeyFunction · 0.70
RFunction · 0.70
generateIdFunction · 0.70
createStyledComponentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected